Support to register a new email address via REST
By PUT on /accounts/<account-id>/emails/<email-id> a new email address can be registered for an account. A verification email is sent with a link that needs to be visited to confirm the email address. The WebUI was adapted to use this REST endpoint for registering email addresses. The old RPC to do this was removed. Change-Id: I39c1f72a0c3e0d50883c76c975bbd464f1894095 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.AcceptsCreate;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
@@ -29,20 +30,23 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class Emails implements
|
||||
ChildCollection<AccountResource, AccountResource.Email> {
|
||||
ChildCollection<AccountResource, AccountResource.Email>,
|
||||
AcceptsCreate<AccountResource> {
|
||||
private final DynamicMap<RestView<AccountResource.Email>> views;
|
||||
private final Provider<GetEmails> get;
|
||||
private final AccountByEmailCache byEmailCache;
|
||||
private final Provider<CurrentUser> self;
|
||||
private final CreateEmail.Factory createEmailFactory;
|
||||
|
||||
@Inject
|
||||
Emails(DynamicMap<RestView<AccountResource.Email>> views,
|
||||
Provider<GetEmails> get, AccountByEmailCache byEmailCache,
|
||||
Provider<CurrentUser> self) {
|
||||
Provider<CurrentUser> self, CreateEmail.Factory createEmailFactory) {
|
||||
this.views = views;
|
||||
this.get = get;
|
||||
this.byEmailCache = byEmailCache;
|
||||
this.self = self;
|
||||
this.createEmailFactory = createEmailFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,4 +84,10 @@ public class Emails implements
|
||||
public DynamicMap<RestView<Email>> views() {
|
||||
return views;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public CreateEmail create(AccountResource parent, IdString email) {
|
||||
return createEmailFactory.create(email.get());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user