fix(auth): SSO return_to без /me чтобы не бить rate limit
Build and Push Auth Portal Docker Image / build-and-push (push) Successful in 2m49s
Build and Push Auth Portal Docker Image / create-release (push) Skipped

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-07-18 14:09:21 +07:00
co-authored by Cursor
parent 961242506b
commit 4ff440fb34
+9 -6
View File
@@ -18,21 +18,24 @@ export const Route = createFileRoute('/')({
beforeLoad: async ({ search }) => {
const token = getToken()
if (!token) return
try {
const me = await api.get<MeResponse>('/api/v1/auth/me')
// SSO handoff first — avoid /me round-trip (rate-limit loops under redirect storms)
if (search.return_to) {
const allowlist = await ensureReturnToAllowlist()
if (
search.return_to &&
isReturnToAllowed(search.return_to, allowlist)
) {
if (isReturnToAllowed(search.return_to, allowlist)) {
const exp = new Date(Date.now() + 60 * 60 * 1000).toISOString()
window.location.href = buildSsoRedirectUrl(
search.return_to,
token,
exp,
)
await new Promise(() => {})
return
}
}
try {
const me = await api.get<MeResponse>('/api/v1/auth/me')
throw redirect({ to: me.is_admin ? '/admin' : '/apps' })
} catch (err) {
if (err && typeof err === 'object' && 'to' in err) throw err