fix: sso环境下没有后台管理权限会进入无限循环

This commit is contained in:
dolphin
2026-05-15 21:54:23 +08:00
parent 26ff546809
commit 6df09bf1dd
@@ -1,6 +1,5 @@
import { toast } from "@/components/bs-ui/toast/use-toast";
import { resolveRoutePermissions } from "@/routes";
import { navigateBackOrFallback } from "@/utils/navigation";
import { getWorkspaceClientUrl } from "@/utils/workspaceUrl";
import i18next from "i18next";
import { ReactNode, createContext, useLayoutEffect, useState } from "react";
@@ -174,7 +173,12 @@ export function UserProvider({ children }: { children: ReactNode }) {
variant: 'error',
description: i18next.t('menu.noAdminConsoleAccess'),
})
navigateBackOrFallback(getWorkspaceClientUrl('/'))
// Hard-navigate to the workspace client. Must NOT use history.back()
// here: under the SSO flow the previous history entry is the IdP /
// portal page, so "going back" silently re-triggers SSO and produces
// an infinite redirect loop for non-admin users. replace() also drops
// the un-usable platform URL from history.
window.location.replace(getWorkspaceClientUrl('/'))
return
}