diff --git a/server/account/src/operations.ts b/server/account/src/operations.ts index d78d19e9675..00ebb204922 100644 --- a/server/account/src/operations.ts +++ b/server/account/src/operations.ts @@ -97,7 +97,7 @@ import { sendEmailConfirmation, sendOtp, setPassword, - setTimezoneIfNotDefined, + setTimezone, signUpByEmail, updateWorkspaceRole, verifyAllowedRole, @@ -281,7 +281,7 @@ export async function signUp ( await confirmHulyIds(ctx, db, account) } - void setTimezoneIfNotDefined(ctx, db, account, null, meta) + void setTimezone(ctx, db, account, null, meta) return { account, name: getPersonName(person), @@ -1151,7 +1151,7 @@ export async function signUpJoin ( }) const { account } = await signUpByEmail(ctx, db, branding, email, password, first, last ?? '', true) - void setTimezoneIfNotDefined(ctx, db, account, null, meta) + void setTimezone(ctx, db, account, null, meta) return await doJoinByInvite( ctx, @@ -1749,7 +1749,7 @@ export async function getLoginInfoByToken ( } if (!isSystem) { - void setTimezoneIfNotDefined(ctx, db, accountUuid, null, meta) + void setTimezone(ctx, db, accountUuid, null, meta) } if (workspaceUuid != null && workspaceUuid !== '') { diff --git a/server/account/src/utils.ts b/server/account/src/utils.ts index b59fb90dcf2..d114a710d70 100644 --- a/server/account/src/utils.ts +++ b/server/account/src/utils.ts @@ -709,7 +709,7 @@ export async function selectWorkspace ( } if (accountUuid !== systemAccountUuid && meta !== undefined) { - void setTimezoneIfNotDefined(ctx, db, accountUuid, account, meta) + void setTimezone(ctx, db, accountUuid, account, meta) } if (role === AccountRole.ReadOnlyGuest) { @@ -1780,7 +1780,7 @@ export function generatePassword (len: number = 24): string { return randomBytes(len).toString('base64').slice(0, len) } -export async function setTimezoneIfNotDefined ( +export async function setTimezone ( ctx: MeasureContext, db: AccountDB, accountId: AccountUuid, @@ -1794,7 +1794,7 @@ export async function setTimezoneIfNotDefined ( ctx.warn('Failed to find account') return } - if (existingAccount.timezone != null) return + if (existingAccount.timezone === meta?.timezone) return await db.account.update({ uuid: accountId }, { timezone: meta.timezone }) } catch (err: any) { ctx.error('Failed to set account timezone', err)