Skip to content

Commit

Permalink
fix: rectify auth issue after new usr mgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceix committed Aug 24, 2024
1 parent cc21e41 commit e6c2599
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pages/auth/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) });
}
Expand Down
3 changes: 3 additions & 0 deletions src/services/BaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand All @@ -31,6 +32,7 @@ export async function setupTenantConfig(): Promise<void> {
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;
Expand Down Expand Up @@ -96,6 +98,7 @@ export async function setupTenantConfig(): Promise<void> {
amuiUserId: amuiUserId || (window?.localStorage?.getItem(NMUI_AMUI_USER_ID_LOCALSTORAGE_KEY) ?? ''),
isNewTenant: isNewTenant,
// user,
// userPlatformRole,
});
}

Expand Down

0 comments on commit e6c2599

Please sign in to comment.