Store all emails in lowercase

This commit is contained in:
Colin McDonald 2016-08-17 20:44:39 -04:00
parent 2f60ce2aa7
commit b3d8ab2fbd

View File

@ -133,7 +133,7 @@ public final class User {
} }
public static void findByConfirmedEmail(String email, SingleResultCallback<User> callback) { public static void findByConfirmedEmail(String email, SingleResultCallback<User> callback) {
usersCollection.find(new Document("email", email)).first(SyncUtils.vertxWrap(callback)); usersCollection.find(new Document("email", email.toLowerCase())).first(SyncUtils.vertxWrap(callback));
} }
public static void findByPasswordResetToken(String passwordResetToken, SingleResultCallback<User> callback) { public static void findByPasswordResetToken(String passwordResetToken, SingleResultCallback<User> callback) {
@ -535,13 +535,13 @@ public final class User {
} }
public void startEmailRegistration(String pendingEmail) { public void startEmailRegistration(String pendingEmail) {
this.pendingEmail = pendingEmail; this.pendingEmail = pendingEmail.toLowerCase();
this.pendingEmailToken = UUID.randomUUID().toString().replace("-", ""); this.pendingEmailToken = UUID.randomUUID().toString().replace("-", "");
this.pendingEmailTokenSetAt = Instant.now(); this.pendingEmailTokenSetAt = Instant.now();
} }
public void completeEmailRegistration(String email) { public void completeEmailRegistration(String email) {
this.email = email; this.email = email.toLowerCase();
this.registeredAt = Instant.now(); this.registeredAt = Instant.now();
this.pendingEmail = null; this.pendingEmail = null;
this.pendingEmailToken = null; this.pendingEmailToken = null;