Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Deleted users - Constraint violated on login - Soft Deletes #181

Closed
eleftrik opened this issue Sep 27, 2016 · 5 comments
Closed

Deleted users - Constraint violated on login - Soft Deletes #181

eleftrik opened this issue Sep 27, 2016 · 5 comments
Labels

Comments

@eleftrik
Copy link

In my users table, If I soft delete a user (deleted_at is not null), when I try to login as that user, I got a unique constraint violation:

Oci8Exception in Statement.php line 177: Error Code : 1
Error Message : ORA-00001: unique constraint (INTRANET.USERS_USERNAME_UK) violated
Position : 0
Statement : insert into users (username, "password", name, surname, description, office, badge, serial_number, email, updated_at, created_at) values (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10) returning id into :p11

How can I

  1. avoid this error
  2. return (in the login form) a message like "this user has been disabled"

I use Laravel 5.3 authentication scaffolding.

Thank you

@stevebauman
Copy link
Member

Hi @eleftrik, completely forgot about this situation with soft deleted users.

Going to patch this now, thanks!

@stevebauman stevebauman changed the title Deleted users - Constraint violated on login Deleted users - Constraint violated on login - Soft Deletes Sep 27, 2016
@eleftrik
Copy link
Author

Hi @stevebauman, thank you very much, I'll wait for the patch.

@stevebauman
Copy link
Member

Hi @eleftrik, patched now, but need to add some tests for this before release, but you can definitely utilize dev-master right now if you wish.

@eleftrik
Copy link
Author

Thank you @stevebauman, I used dev-master, and now I correctly cannot authenticate as soft deleted user and I got no more database constraint errors.

Is there a way to discriminate between an incorrect login (non-existing user, wrong credentials, etc.) and a soft-deleted user which tries to authenticate (entering correct credentials)?
In this case, I would like to output a different error message (e. g. "Your account has been disabled. Please contact an administrator")

Thanks

@stevebauman
Copy link
Member

Is there a way to discriminate between an incorrect login (non-existing user, wrong credentials, etc.) and a soft-deleted user which tries to authenticate (entering correct credentials)?

No, but that's a great point. I need to add events for this situation so you can add errors to the session if needed. I'll implement this now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants