Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rectify auth issue after new usr mgmt #717

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading