Add more debug logging to account creation
As explained in issue 8803 new LDAP users are still facing issues due to missing DB entries. These extra log statements can help to get a more focused idea of the problem in the future. Bug: Issue 8803 Change-Id: I03df282d0611259d196160082cd787ed8232bb79
This commit is contained in:
@@ -214,10 +214,12 @@ public class AccountManager {
|
||||
private AuthResult create(ReviewDb db, AuthRequest who)
|
||||
throws OrmException, AccountException, IOException, ConfigInvalidException {
|
||||
Account.Id newId = new Account.Id(db.nextAccountId());
|
||||
log.debug("Assigning new Id {} to account", newId);
|
||||
Account account = new Account(newId, TimeUtil.nowTs());
|
||||
|
||||
ExternalId extId =
|
||||
ExternalId.createWithEmail(who.getExternalIdKey(), newId, who.getEmailAddress());
|
||||
log.debug("Created external Id: {}", extId);
|
||||
account.setFullName(who.getDisplayName());
|
||||
account.setPreferredEmail(extId.email());
|
||||
|
||||
@@ -272,10 +274,13 @@ public class AccountManager {
|
||||
db.accountGroupMembers().insert(Collections.singleton(m));
|
||||
}
|
||||
|
||||
log.debug("Username from AuthRequest: {}", who.getUserName());
|
||||
if (who.getUserName() != null) {
|
||||
log.debug("Setting username for: {}", who.getUserName());
|
||||
// Only set if the name hasn't been used yet, but was given to us.
|
||||
//
|
||||
IdentifiedUser user = userFactory.create(newId);
|
||||
log.debug("Identified user {} was created from {}", user, who.getUserName());
|
||||
try {
|
||||
changeUserNameFactory.create(db, user, who.getUserName()).call();
|
||||
} catch (NameAlreadyUsedException e) {
|
||||
|
||||
@@ -33,13 +33,16 @@ import java.util.Collection;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.regex.Pattern;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** Operation to change the username of an account. */
|
||||
public class ChangeUserName implements Callable<VoidResult> {
|
||||
public static final String USERNAME_CANNOT_BE_CHANGED = "Username cannot be changed.";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeUserName.class);
|
||||
private static final Pattern USER_NAME_PATTERN = Pattern.compile(Account.USER_NAME_PATTERN);
|
||||
|
||||
public static final String USERNAME_CANNOT_BE_CHANGED = "Username cannot be changed.";
|
||||
|
||||
/** Generic factory to change any user's username. */
|
||||
public interface Factory {
|
||||
ChangeUserName create(ReviewDb db, IdentifiedUser user, String newUsername);
|
||||
@@ -79,6 +82,9 @@ public class ChangeUserName implements Callable<VoidResult> {
|
||||
.filter(e -> e.isScheme(SCHEME_USERNAME))
|
||||
.collect(toSet());
|
||||
if (!old.isEmpty()) {
|
||||
log.error(
|
||||
"External id with scheme \"username:\" already exists for the user {}",
|
||||
user.getAccountId());
|
||||
throw new IllegalStateException(USERNAME_CANNOT_BE_CHANGED);
|
||||
}
|
||||
|
||||
@@ -97,6 +103,7 @@ public class ChangeUserName implements Callable<VoidResult> {
|
||||
}
|
||||
}
|
||||
externalIdsUpdate.insert(db, ExternalId.create(key, user.getAccountId(), null, password));
|
||||
log.info("Created the new external Id with key: {}", key);
|
||||
} catch (OrmDuplicateKeyException dupeErr) {
|
||||
// If we are using this identity, don't report the exception.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user