Prevent duplicate email addresses

This commit is contained in:
Colin McDonald 2016-06-26 21:48:26 -04:00
parent 8740d32621
commit 9f4089a752

View File

@ -53,6 +53,14 @@ public final class POSTUsersIdRegister implements Handler<RoutingContext> {
return;
}
BlockingCallback<User> sameEmailCallback = new BlockingCallback<>();
User.findByEmail(email, sameEmailCallback);
if (sameEmailCallback.get() != null) {
ErrorUtils.respondInvalidInput(ctx, email + " is already in use.");
return;
}
user.startRegistration(email);
BlockingCallback<UpdateResult> callback = new BlockingCallback<>();
user.save(callback);