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

Resetting database doen't allow people to login #168

Closed
1 task
SimonLab opened this issue Oct 7, 2022 · 3 comments
Closed
1 task

Resetting database doen't allow people to login #168

SimonLab opened this issue Oct 7, 2022 · 3 comments
Labels
bug Suspected or confirmed bug (defect) in the code priority-1 Highest priority issue. This is costing us money every minute that passes.

Comments

@SimonLab
Copy link
Member

SimonLab commented Oct 7, 2022

The following plug will check if the name of the person is defined and redirect to the profile page if it doesn't:

defp profile_name(conn, _opts) do
person_id = conn.assigns[:person][:id] || 0
person = Person.get_person!(person_id)
if is_nil(person.name) do
conn
|> put_flash(:info, "Add a name to your profile to allow sharing items")
|> redirect(to: "/profile/#{person.person_id}/edit")
|> halt()
else
conn
end
end

However the first time a person login, the person = Person.get_person!(person_id) will fail and throw an error as the person is not yet added to the database.

  • Use upsert to add the new person to the database
@SimonLab SimonLab added the bug Suspected or confirmed bug (defect) in the code label Oct 7, 2022
@SimonLab SimonLab self-assigned this Oct 7, 2022
@SimonLab SimonLab added the priority-1 Highest priority issue. This is costing us money every minute that passes. label Oct 7, 2022
@nelsonic
Copy link
Member

nelsonic commented Oct 7, 2022

@SimonLab thanks for opening this issue and diving straight into addressing it. 👌

SimonLab added a commit that referenced this issue Oct 8, 2022
- Add test for item controller managing lists
- Fix #168
SimonLab added a commit that referenced this issue Oct 8, 2022
- Add test for item controller managing lists
- Fix #168
@SimonLab
Copy link
Member Author

SimonLab commented Oct 8, 2022

This will be fixed with #165

@SimonLab SimonLab added the awaiting-review An issue or pull request that needs to be reviewed label Oct 8, 2022
@SimonLab
Copy link
Member Author

done with #182

@SimonLab SimonLab removed the awaiting-review An issue or pull request that needs to be reviewed label Nov 30, 2022
@SimonLab SimonLab removed their assignment Nov 30, 2022
nelsonic pushed a commit that referenced this issue Sep 8, 2023
- Add test for item controller managing lists
- Fix #168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Suspected or confirmed bug (defect) in the code priority-1 Highest priority issue. This is costing us money every minute that passes.
Projects
None yet
Development

No branches or pull requests

2 participants