User deleted by admin cannot sign in again.
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.
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.