Confirm email: Return proper error when email is used by other account
So far trying to confirm an email address that is already in use by another account was failing with 500 Internal Server Error. Change-Id: I97830491cc198f582fa4192de1276a4af7d12ce2 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -62,4 +62,13 @@ public class ConfirmEmailIT extends AbstractDaemonTest {
|
||||
.put("/config/server/email.confirm", in)
|
||||
.assertUnprocessableEntity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void confirmAlreadyInUse_UnprocessableEntity() throws Exception {
|
||||
ConfirmEmail.Input in = new ConfirmEmail.Input();
|
||||
in.token = emailTokenVerifier.encode(admin.getId(), user.email);
|
||||
adminRestSession
|
||||
.put("/config/server/email.confirm", in)
|
||||
.assertUnprocessableEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ public class ConfirmEmail implements RestModifyView<ConfigResource, Input> {
|
||||
throw new UnprocessableEntityException("invalid token");
|
||||
} catch (EmailTokenVerifier.InvalidTokenException e) {
|
||||
throw new UnprocessableEntityException("invalid token");
|
||||
} catch (AccountException e) {
|
||||
throw new UnprocessableEntityException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user