more profileConfig rename

This commit is contained in:
Girish Ramakrishnan
2022-01-13 15:20:16 -08:00
parent e9945d8010
commit 97e439f8a3
5 changed files with 49 additions and 36 deletions

View File

@@ -546,7 +546,9 @@ async function update(user, data, auditSource) {
if (_.isEmpty(data)) return;
if (data.username) {
if (user.username) throw new BoxError(BoxError.BAD_FIELD, 'Username cannot be changed');
// regardless of "account setup", username cannot be changed because admin could have logged in with temp password and apps
// already know about it
if (user.username) throw new BoxError(BoxError.CONFLICT, 'Username cannot be changed');
data.username = data.username.toLowerCase();
error = validateUsername(data.username);
if (error) throw error;
@@ -757,7 +759,7 @@ async function getInviteLink(user, auditSource) {
if (user.source) throw new BoxError(BoxError.CONFLICT, 'User is from an external directory');
if (!user.inviteToken) throw new BoxError(BoxError.BAD_STATE, 'User already used invite link');
const directoryConfig = await settings.getDirectoryConfig();
const directoryConfig = await settings.getProfileConfig();
let inviteLink = `${settings.dashboardOrigin()}/setupaccount.html?inviteToken=${user.inviteToken}&email=${encodeURIComponent(user.email)}`;
if (user.username) inviteLink += `&username=${encodeURIComponent(user.username)}`;
@@ -784,13 +786,15 @@ async function setupAccount(user, data, auditSource) {
assert.strictEqual(typeof data, 'object');
assert(auditSource && typeof auditSource === 'object');
const directoryConfig = await settings.getDirectoryConfig();
const profileConfig = await settings.getProfileConfig();
var tmp = { inviteToken: '' };
if (!directoryConfig.lockUserProfiles) {
tmp.username = data.username;
tmp.displayName = data.displayName;
if (profileConfig.lockUserProfiles) {
if (!user.username) throw new BoxError(BoxError.CONFLICT, 'Account cannot be setup without a username'); // error out if admin has not provided a username
} else {
if (data.username) tmp.username = data.username;
if (data.displayName) tmp.displayName = data.displayName;
}
await update(user, tmp, auditSource);