Fix profile test

This commit is contained in:
Girish Ramakrishnan
2025-08-14 16:02:54 +05:30
parent f2225ff6b6
commit 942e595444
2 changed files with 64 additions and 64 deletions

View File

@@ -887,6 +887,14 @@ async function setupAccount(user, data, auditSource) {
assert.strictEqual(typeof data, 'object');
assert(auditSource && typeof auditSource === 'object');
const profileConfig = await userDirectory.getProfileConfig();
// error out if admin has not provided a username
if (profileConfig.lockUserProfiles) {
if (!user.username) throw new BoxError(BoxError.CONFLICT, 'Account cannot be setup without a username');
if (data.username) throw new BoxError(BoxError.CONFLICT, 'Username cannot be changed because profiles are locked');
}
const tmp = { inviteToken: '' };
if (data.username) {
@@ -906,13 +914,6 @@ async function setupAccount(user, data, auditSource) {
const error = validatePassword(data.password);
if (error) throw error;
const profileConfig = await userDirectory.getProfileConfig();
// error out if admin has not provided a username
if (profileConfig.lockUserProfiles && !user.username) {
throw new BoxError(BoxError.CONFLICT, 'Account cannot be setup without a username');
}
await update(user, tmp, auditSource);
await setPassword(user, data.password, auditSource);