From 4e8fdac8cd6e5b600d16f95c24018ca88b259055 Mon Sep 17 00:00:00 2001 From: Hrvoje Fekete Date: Fri, 6 Dec 2024 09:58:09 -0800 Subject: [PATCH] 24755 - fix: when and how is account fetched. (#98) --- src/components/bcros/header/Index.vue | 4 +++- src/middleware/02.setupAuth.global.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/bcros/header/Index.vue b/src/components/bcros/header/Index.vue index 24b26732..3157726c 100644 --- a/src/components/bcros/header/Index.vue +++ b/src/components/bcros/header/Index.vue @@ -89,7 +89,9 @@ const { createAccount, logout } = useBcrosAuth() function switchAccount (accountId: number) { account.switchCurrentAccount(accountId) // refresh the page so that account based checks are rerun - window.location.reload() + const url = new URL(window.location) + url.searchParams.set('accountid', accountId.toString()) + window.location.assign(url.toString()) } // logged out menu options diff --git a/src/middleware/02.setupAuth.global.ts b/src/middleware/02.setupAuth.global.ts index cf003a97..7b0b8954 100644 --- a/src/middleware/02.setupAuth.global.ts +++ b/src/middleware/02.setupAuth.global.ts @@ -35,6 +35,7 @@ export default defineNuxtRouteMiddleware(async (to) => { // set account stuff (normally would happen after kc init in 'setupAuth') const account = useBcrosAccount() await account.setUserName() - await account.setAccountInfo() + const accountNumber = to?.params?.accountid || to?.query?.accountid || undefined + await account.setAccountInfo(+accountNumber) } })