fix some for iam
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Ported from legacy henza_admin/src/store/auth/moduleAuth.js
|
||||
import { defineStore } from 'pinia';
|
||||
import api from '../api/client';
|
||||
import { tokenName, userName } from '../utils';
|
||||
import { iamAppUrl, tokenName, userName } from '../utils';
|
||||
import { useUsersStore } from './users';
|
||||
import type { UserInfo } from './users';
|
||||
|
||||
@@ -67,6 +67,9 @@ export const useAuthStore = defineStore('auth', {
|
||||
delete persisted.ut;
|
||||
|
||||
this.inject(persisted);
|
||||
if (data.iamBootstrapUrl) {
|
||||
window.location.assign(data.iamBootstrapUrl);
|
||||
}
|
||||
return persisted;
|
||||
},
|
||||
|
||||
@@ -83,13 +86,28 @@ export const useAuthStore = defineStore('auth', {
|
||||
* its module-scoped `roles` survived a session change (bug #2). Clearing
|
||||
* both storage and the roles store is the fix for that.
|
||||
*/
|
||||
logout() {
|
||||
async logout(): Promise<boolean> {
|
||||
let central: string | null = null;
|
||||
try {
|
||||
const { data } = await api.get('admin/auth/sso/logout-url', {
|
||||
params: { return_url: iamAppUrl('auth/login') },
|
||||
});
|
||||
central = data?.logout_url ?? null;
|
||||
} catch {
|
||||
central = null;
|
||||
}
|
||||
localStorage.removeItem(tokenName);
|
||||
localStorage.removeItem(userName);
|
||||
localStorage.removeItem('login');
|
||||
sessionStorage.removeItem('gb_admin_iam_sso_checked');
|
||||
const users = useUsersStore();
|
||||
users.deleteRoles();
|
||||
users.deleteUserInfo();
|
||||
if (central) {
|
||||
window.location.assign(central);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user