From 84ffc706621069f0929d1be6b176b4cac1b5121b Mon Sep 17 00:00:00 2001 From: Kenny Jung Date: Wed, 10 Apr 2024 01:56:20 -0400 Subject: [PATCH] Save emails as lowercase --- .../dataaccess/AuthDatabaseOperations.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/service/src/main/java/com/codeforcommunity/dataaccess/AuthDatabaseOperations.java b/service/src/main/java/com/codeforcommunity/dataaccess/AuthDatabaseOperations.java index 13bc581f..1891b050 100644 --- a/service/src/main/java/com/codeforcommunity/dataaccess/AuthDatabaseOperations.java +++ b/service/src/main/java/com/codeforcommunity/dataaccess/AuthDatabaseOperations.java @@ -131,8 +131,9 @@ public boolean isValidLogin(String email, String pass) { * table. */ public UsersRecord createNewUser(NewUserRequest request) { - String email = request.getEmail(); - boolean emailUsed = db.fetchExists(db.selectFrom(USERS).where(USERS.EMAIL.equalIgnoreCase(email))); + String email = request.getEmail().toLowerCase(); + boolean emailUsed = + db.fetchExists(db.selectFrom(USERS).where(USERS.EMAIL.equalIgnoreCase(email))); if (emailUsed) { throw new EmailAlreadyInUseException(email); } @@ -143,7 +144,7 @@ public UsersRecord createNewUser(NewUserRequest request) { UsersRecord newUser = db.newRecord(USERS); addAddressDataToUserRecord(newUser, request.getLocation()); - newUser.setEmail(request.getEmail()); + newUser.setEmail(email); newUser.setPassHash(Passwords.createHash(request.getPassword())); newUser.setPrivilegeLevel(PrivilegeLevel.STANDARD); newUser.setPhotoRelease(request.getPhotoRelease());