diff --git a/app/stores/AuthStore.ts b/app/stores/AuthStore.ts index 742d12b669..125c7f87fc 100644 --- a/app/stores/AuthStore.ts +++ b/app/stores/AuthStore.ts @@ -218,19 +218,13 @@ export default class AuthStore extends Store { this.collaborationToken = res.data.collaborationToken; if (env.SENTRY_DSN) { - Sentry.configureScope(function (scope) { - scope.setUser({ id: this.currentUserId }); - scope.setExtra("team", this.team.name); - scope.setExtra("teamId", this.team.id); + Sentry.configureScope((scope) => { + scope.setUser({ id: this.currentUserId! }); + scope.setExtra("team", this.team?.name); + scope.setExtra("teamId", this.currentTeamId); }); } - const currTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - if (data.user.timezone !== currTimezone) { - const user = this.rootStore.users.get(data.user.id)!; - void user.save({ timezone: currTimezone }); - } - // Redirect to the correct custom domain or team subdomain if needed // Occurs when the (sub)domain is changed in admin and the user hits an old url const { hostname, pathname } = window.location; @@ -247,6 +241,13 @@ export default class AuthStore extends Store { window.location.href = `${data.team.url}${pathname}`; return; } + + // Update the user's timezone if it has changed + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + if (data.user.timezone !== timezone) { + const user = this.rootStore.users.get(data.user.id)!; + void user.save({ timezone }); + } }); } catch (err) { if (err.error === "user_suspended") { @@ -254,6 +255,7 @@ export default class AuthStore extends Store { this.suspendedContactEmail = err.data.adminEmail; return; } + throw err; } finally { this.isFetching = false; }