Allow adding users who are missing a preferred_email
If the user account has not yet selected a preferred_email value then the user completion uses "Full Name (ID)" as the value we suggest for addition to the change or group. Instead of failing to find the user we now parse the ID component and honor it. Bug: issue 152 Change-Id: I72dbaef4a2b8a8bff7e5d5a8fbb65203c64b5127 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -23,6 +23,8 @@ import com.google.inject.Provider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AccountResolver {
|
||||
private final Realm realm;
|
||||
@@ -49,6 +51,11 @@ public class AccountResolver {
|
||||
* there are multiple candidates.
|
||||
*/
|
||||
public Account find(final String nameOrEmail) throws OrmException {
|
||||
Matcher m = Pattern.compile("^.* \\(([1-9][0-9]*)\\)$").matcher(nameOrEmail);
|
||||
if (m.matches()) {
|
||||
return byId.get(Account.Id.parse(m.group(1))).getAccount();
|
||||
}
|
||||
|
||||
if (nameOrEmail.matches("^[1-9][0-9]*$")) {
|
||||
return byId.get(Account.Id.parse(nameOrEmail)).getAccount();
|
||||
}
|
||||
|
Reference in New Issue
Block a user