Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User deleted by admin cannot sign in again. #334

Open
paulrusu8 opened this issue Mar 19, 2019 · 1 comment
Open

User deleted by admin cannot sign in again. #334

paulrusu8 opened this issue Mar 19, 2019 · 1 comment

Comments

@paulrusu8
Copy link

When I delete a user from the admin app, re-register with the same user information and then try to sign in, I get following error message:
[error] #PID<0.958.0> running SnitchApiWeb.Endpoint (cowboy_protocol) terminated
Server: localhost:3000 (http)
Request: POST /api/v1/login
(exit) an exception was raised: (Ecto.MultipleResultsError) expected at most one result but got 5 in query:
However, the user is deleted in the users list retrieved in the admin app.

@paulrusu8
Copy link
Author

I solved the problem by changing, in the ~/avia-develop/apps/snitch_core/lib/core/data/model/user.ex file,
the Repo.update to Repo.delete on line 23. As this change prompted

** (Ecto.ConstraintError) constraint error when attempting to delete struct:

 * foreign_key: snitch_orders_user_id_fkey,

I dropped this constraint manually in a postgresql console and it worked.

However, I have the feeling that this workaround is clunky, cumbersome, and potentially dangerous. With that being said, I am very curious whether anyone can think of a more elegant, straightforward, and safe alternative.

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

No branches or pull requests

1 participant