From e6c2599936bb763bb64ce01bf6d3308b254e2324 Mon Sep 17 00:00:00 2001 From: the_aceix Date: Sat, 24 Aug 2024 15:44:12 +0000 Subject: [PATCH] fix: rectify auth issue after new usr mgmt --- src/pages/auth/LoginPage.tsx | 2 ++ src/services/BaseService.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/pages/auth/LoginPage.tsx b/src/pages/auth/LoginPage.tsx index 7c9a494e..ff9fc623 100644 --- a/src/pages/auth/LoginPage.tsx +++ b/src/pages/auth/LoginPage.tsx @@ -12,6 +12,7 @@ import { NMUI_ACCESS_TOKEN_LOCALSTORAGE_KEY, NMUI_USERNAME_LOCALSTORAGE_KEY, NMUI_USER_LOCALSTORAGE_KEY, + NMUI_USER_PLATFORM_ROLE_LOCALSTORAGE_KEY, isSaasBuild, } from '../../services/BaseService'; import { extractErrorMsg } from '@/utils/ServiceUtils'; @@ -66,6 +67,7 @@ export default function LoginPage(props: LoginPageProps) { store.setStore({ user }); window?.localStorage?.setItem(NMUI_USER_LOCALSTORAGE_KEY, JSON.stringify(user)); + window?.localStorage?.setItem(NMUI_USER_PLATFORM_ROLE_LOCALSTORAGE_KEY, JSON.stringify(user.platform_role)); } catch (err) { notify.error({ message: 'Failed to get user details', description: extractErrorMsg(err as any) }); } diff --git a/src/services/BaseService.ts b/src/services/BaseService.ts index d166f898..6ca7be62 100644 --- a/src/services/BaseService.ts +++ b/src/services/BaseService.ts @@ -20,6 +20,7 @@ export const NMUI_TENANT_ID_LOCALSTORAGE_KEY = 'nmui-tid-lsk'; export const NMUI_TENANT_NAME_LOCALSTORAGE_KEY = 'nmui-tn-lsk'; export const NMUI_AMUI_USER_ID_LOCALSTORAGE_KEY = 'nmui-amuiuid-lsk'; export const NMUI_USER_LOCALSTORAGE_KEY = 'nmui-u-lsk'; +export const NMUI_USER_PLATFORM_ROLE_LOCALSTORAGE_KEY = 'nmui-upr-lsk'; // function to resolve the particular SaaS tenant's backend URL, ... export async function setupTenantConfig(): Promise { @@ -31,6 +32,7 @@ export async function setupTenantConfig(): Promise { jwt: window?.localStorage?.getItem(NMUI_ACCESS_TOKEN_LOCALSTORAGE_KEY) ?? '', username: window?.localStorage?.getItem(NMUI_USERNAME_LOCALSTORAGE_KEY) ?? '', user: JSON.parse(window?.localStorage?.getItem(NMUI_USER_LOCALSTORAGE_KEY) ?? 'null'), + userPlatformRole: JSON.parse(window?.localStorage?.getItem(NMUI_USER_PLATFORM_ROLE_LOCALSTORAGE_KEY) ?? 'null'), }); axiosService.defaults.baseURL = resolvedBaseUrl; return; @@ -96,6 +98,7 @@ export async function setupTenantConfig(): Promise { amuiUserId: amuiUserId || (window?.localStorage?.getItem(NMUI_AMUI_USER_ID_LOCALSTORAGE_KEY) ?? ''), isNewTenant: isNewTenant, // user, + // userPlatformRole, }); }