Skip to content

Commit

Permalink
πŸžπŸ”¨Authentication Prevent a condition when double-tapping sign-in
Browse files Browse the repository at this point in the history
- #1809

OK, so my working assumption is that the bug is caused by two requests
being processed at the same time for a new email address, and the first
one creates the `AuthenticationMethod` and the second one *tries* to,
and fails; resulting in the validation error.

This fixes the racecondition at the controller level, but I think we
want to do it at in AuthenticatedSession#save instead...
  • Loading branch information
zspencer committed Oct 12, 2023
1 parent c4446ba commit d8b04cf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/authenticated_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def create
else
render :create, status: :unprocessable_entity
end
rescue ActiveRecord::RecordInvalid
@authenticated_session = nil
if authenticated_session.save
redirect_to(current_space.presence || :root)
else
render :create, status: :unprocessable_entity
end
end

alias_method :update, :create
Expand Down

0 comments on commit d8b04cf

Please sign in to comment.