diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java index a4c39e07aa..ee337981db 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java @@ -14,7 +14,6 @@ package com.google.gerrit.server.account; -import static com.google.gerrit.server.account.ExternalId.SCHEME_USERNAME; import static java.util.stream.Collectors.toSet; import com.google.common.base.Strings; @@ -108,23 +107,8 @@ public class AccountManager { try (ReviewDb db = schema.open()) { ExternalId id = findExternalId(db, who.getExternalIdKey()); if (id == null) { - if (who.getUserName() != null) { - ExternalId.Key key = ExternalId.Key.create(SCHEME_USERNAME, who.getUserName()); - ExternalId existingId = findExternalId(db, key); - if (existingId != null) { - // An inconsistency is detected in the database, having a record for scheme - // "username:" - // but no record for scheme "gerrit:". Try to recover by linking - // "gerrit:" identity to the existing account. - log.warn( - "User {} already has an account; link new identity to the existing account.", - who.getUserName()); - return link(existingId.accountId(), who); - } - } // New account, automatically create and return. // - log.debug("External ID not found. Attempting to create new account."); return create(db, who); } @@ -367,16 +351,13 @@ public class AccountManager { public AuthResult link(Account.Id to, AuthRequest who) throws AccountException, OrmException, IOException { try (ReviewDb db = schema.open()) { - log.debug("Link another authentication identity to an existing account"); ExternalId extId = findExternalId(db, who.getExternalIdKey()); if (extId != null) { if (!extId.accountId().equals(to)) { throw new AccountException("Identity in use by another account"); } - log.debug("Updating existing external ID data"); update(db, who, extId); } else { - log.debug("Linking new external ID to the existing account"); externalIdsUpdateFactory .create() .insert(