Fix some for iam
This commit is contained in:
@@ -94,12 +94,26 @@ export const router = createRouter({
|
||||
// user away from /login, and blocks unauthenticated access to routes that
|
||||
// require a session (legacy blocked ordersList/transactionsList/profileData/
|
||||
// favoritesList/completeProfile the same way).
|
||||
// هر بارگذاری کامل صفحه یک بار بررسی میشود. پرچم sessionStorage فقط
|
||||
// همان برگشتِ بیصدا از IAM را متوقف میکند تا صفحهٔ ورود در حلقه نیفتد.
|
||||
let silentSsoAttempted = false;
|
||||
|
||||
function skipSilentSso(): boolean {
|
||||
if (sessionStorage.getItem('gb_iam_sso_skip') === '1') {
|
||||
sessionStorage.removeItem('gb_iam_sso_skip');
|
||||
silentSsoAttempted = true;
|
||||
return true;
|
||||
}
|
||||
return silentSsoAttempted;
|
||||
}
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
const session = useSessionStore();
|
||||
const nav = useNavStore();
|
||||
|
||||
if (!session.isLoggedIn && to.name !== 'iamCallback' && sessionStorage.getItem('gb_iam_sso_checked') !== '1') {
|
||||
sessionStorage.setItem('gb_iam_sso_checked', '1');
|
||||
if (!session.isLoggedIn && to.name !== 'iamCallback' && !skipSilentSso()) {
|
||||
silentSsoAttempted = true;
|
||||
sessionStorage.removeItem('gb_iam_sso_checked');
|
||||
try {
|
||||
const started = await api.ssoStart();
|
||||
if (started.enabled && started.authorize_url) {
|
||||
|
||||
Reference in New Issue
Block a user