Skip to content

Conversation

davidcornu
Copy link
Member

Summary of the problem

When we try to create a session for a locked user

user_session.save!
we end up hitting a validation error
def user_is_unlocked
if user.locked? && !impersonated?
errors.add(:user, "Your HCB account has been locked.")
end
end
which goes unhandled (https://appsignal.com/hack-club/sites/6596247683eb67648f30f807/exceptions/incidents/2036)

Describe your changes

  • Checks whether the user is locked in SessionsHelper#sign_in and throws AccountLockedError
  • Adds handling for AccountLockedError in LoginsController#complete
  • Adds tests to make sure
    • We correctly redirect users
    • We still allow admins to impersonate locked users

@davidcornu davidcornu requested review from a team as code owners August 8, 2025 21:13
Copy link
Member

@sampoder sampoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thank you!

@davidcornu davidcornu added this pull request to the merge queue Aug 11, 2025
Merged via the queue into main with commit b2b9746 Aug 11, 2025
13 checks passed
@davidcornu davidcornu deleted the david/push-snorrolnplnm branch August 11, 2025 14:09
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

Successfully merging this pull request may close these issues.

2 participants