Allow Gerrit admins to add email addresses without confirmation

Change-Id: I386979ef6d8f693e3e4de3f60cd52828b690b4a3
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-05-17 11:21:27 +02:00
parent 3f48c244ee
commit c99e5a6c2d
2 changed files with 20 additions and 7 deletions

View File

@@ -44,6 +44,7 @@ public class CreateEmail implements RestModifyView<AccountResource, Input> {
@DefaultInput
String email;
boolean preferred;
boolean noConfirmation;
}
static interface Factory {
@@ -85,8 +86,13 @@ public class CreateEmail implements RestModifyView<AccountResource, Input> {
if (input.email != null && !email.equals(input.email)) {
throw new BadRequestException("email address must match URL");
}
if (input.noConfirmation && !self.get().getCapabilities().canAdministrateServer()) {
throw new AuthException("not allowed to add email address without confirmation, "
+ "need to be Gerrit administrator");
}
if (authConfig.getAuthType() == AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT) {
if (input.noConfirmation
|| authConfig.getAuthType() == AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT) {
try {
accountManager.link(rsrc.getUser().getAccountId(),
AuthRequest.forEmail(email));