Fix some for iam
This commit is contained in:
@@ -114,9 +114,21 @@ async function getPermission(): Promise<string[] | undefined> {
|
||||
* pending and hangs the app (bug #1). Returning the redirect is the Vue Router 4
|
||||
* equivalent and produces the same user-visible result.
|
||||
*/
|
||||
let silentSsoAttempted = false;
|
||||
|
||||
function skipSilentSso(): boolean {
|
||||
if (sessionStorage.getItem('gb_admin_iam_sso_skip') === '1') {
|
||||
sessionStorage.removeItem('gb_admin_iam_sso_skip');
|
||||
silentSsoAttempted = true;
|
||||
return true;
|
||||
}
|
||||
return silentSsoAttempted;
|
||||
}
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
if (!localStorage.getItem(tokenName) && to.path !== '/auth/iam/callback' && sessionStorage.getItem('gb_admin_iam_sso_checked') !== '1') {
|
||||
sessionStorage.setItem('gb_admin_iam_sso_checked', '1');
|
||||
if (!localStorage.getItem(tokenName) && to.path !== '/auth/iam/callback' && !skipSilentSso()) {
|
||||
silentSsoAttempted = true;
|
||||
sessionStorage.removeItem('gb_admin_iam_sso_checked');
|
||||
try {
|
||||
const { data } = await api.get('admin/auth/sso/start', {
|
||||
params: { redirect_uri: iamAppUrl('auth/iam/callback') },
|
||||
|
||||
@@ -9,9 +9,10 @@ const auth = useAuthStore();
|
||||
|
||||
onMounted(async () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
sessionStorage.setItem('gb_admin_iam_sso_checked', '1');
|
||||
sessionStorage.removeItem('gb_admin_iam_sso_checked');
|
||||
|
||||
if (params.get('error') || !params.get('code') || !params.get('state')) {
|
||||
sessionStorage.setItem('gb_admin_iam_sso_skip', '1');
|
||||
await router.replace('/auth/login');
|
||||
return;
|
||||
}
|
||||
@@ -27,6 +28,7 @@ onMounted(async () => {
|
||||
auth.inject(persisted);
|
||||
await router.replace('/dashboard/ecommerce');
|
||||
} catch {
|
||||
sessionStorage.setItem('gb_admin_iam_sso_skip', '1');
|
||||
await router.replace('/auth/login');
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user