Skip to content

Commit

Permalink
Enhance registration error handling for duplicate player names and em…
Browse files Browse the repository at this point in the history
…ails
  • Loading branch information
Vianpyro committed Nov 19, 2024
1 parent 2b65b1c commit 5ffea94
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions routes/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def register():
cursor.callproc("register_player", (name, email, hashed_password, salt))
db.commit()
except MySQLError as e:
if e.args[0] == 1644:
return jsonify(message="Email already in use"), 400
# Check for specific error messages in the SQL error
if "Player name already exists" in str(e):
return jsonify(message="Player name already exists"), 400
elif "Email already exists" in str(e):
return jsonify(message="Email already exists"), 400
else:
return jsonify(message="An error occurred during registration"), 500

Expand Down

0 comments on commit 5ffea94

Please sign in to comment.