Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
make sure an email address cannot be used more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
tnix100 committed Sep 9, 2024
1 parent 441dcf2 commit 2f8ebca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rest_api/v0/me.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ async def update_email(data: UpdateEmailBody):
if not security.check_password_hash(data.password, account["pswd"]):
security.ratelimit(f"login:u:{request.user}", 5, 60)
return {"error": True, "type": "invalidCredentials"}, 401


# Make sure the email address hasn't been used before
if db.usersv0.count_documents({"normalized_email_hash": security.get_normalized_email_hash(data.email)}, limit=1):
return {"error": True, "type": "emailExists"}, 409

# Ratelimit
security.ratelimit(f"emailch:{request.user}", 3, 2700)

Expand Down

0 comments on commit 2f8ebca

Please sign in to comment.