fix some for iam

This commit is contained in:
Montech
2026-10-07 16:45:36 +03:30
parent a72fa607a5
commit 5223de313a
25 changed files with 823 additions and 38 deletions
+20 -2
View File
@@ -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;
},
},
});