From 655332715dae0a64866b0a797076425b4299817b Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Tue, 21 Jan 2025 09:23:18 +0000 Subject: [PATCH] login platform user after forced password reset (#15406) --- packages/builder/src/pages/builder/auth/reset.svelte | 6 ++++++ packages/builder/src/stores/portal/auth.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/auth/reset.svelte b/packages/builder/src/pages/builder/auth/reset.svelte index 1179618e40..64438c22d5 100644 --- a/packages/builder/src/pages/builder/auth/reset.svelte +++ b/packages/builder/src/pages/builder/auth/reset.svelte @@ -30,10 +30,16 @@ try { loading = true if (forceResetPassword) { + const email = $auth.user.email + const tenantId = $auth.user.tenantId await auth.updateSelf({ password, forceResetPassword: false, }) + if (!$auth.user) { + // Update self will clear the platform user, so need to login + await auth.login(email, password, tenantId) + } $goto("../portal/") } else { await auth.resetPassword(password, resetCode) diff --git a/packages/builder/src/stores/portal/auth.ts b/packages/builder/src/stores/portal/auth.ts index 171b2b43ae..c3dcaa3663 100644 --- a/packages/builder/src/stores/portal/auth.ts +++ b/packages/builder/src/stores/portal/auth.ts @@ -121,8 +121,8 @@ class AuthStore extends BudiStore { } } - async login(username: string, password: string) { - const tenantId = get(this.store).tenantId + async login(username: string, password: string, targetTenantId?: string) { + const tenantId = targetTenantId || get(this.store).tenantId await API.logIn(tenantId, username, password) await this.getSelf() }