fix(auth): activate account on password reset and fix is_active check order
- reset_password sets is_active=True so users with unverified accounts can log in after using the forgot-password flow - admin set_password also sets is_active=True for the same reason - auth() now checks is_active before verifying the password, ensuring inactive users always see the email-verification prompt regardless of password correctness (avoids leaking password validity)" Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -488,9 +488,11 @@ def admin_set_password(
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Local user not found.")
|
||||
|
||||
user.hashed_password = hash_password(body.password)
|
||||
# Clear any outstanding reset tokens
|
||||
# Clear any outstanding reset tokens and activate the account so the user
|
||||
# can log in immediately after an admin sets their password.
|
||||
user.password_reset_token = None
|
||||
user.password_reset_sent_at = None
|
||||
user.is_active = True
|
||||
|
||||
try:
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user