mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
fix(native): the hand-off page goes straight to SSO instead of TREK's login first
The app's browser sign-in opens /native-handoff, which sends the user on to the identity provider by itself. The page was not on the list of public auth pages, so the 401 from loading the user sent the browser to /login with the hand-off as its return path first. On a server that also offers passwords the user then had to pick SSO a second time before getting back to the app.
This commit is contained in:
@@ -145,7 +145,10 @@ apiClient.interceptors.request.use(
|
||||
)
|
||||
|
||||
export function isAuthPublicPath(pathname: string): boolean {
|
||||
const publicPaths = ['/login', '/register', '/forgot-password', '/reset-password']
|
||||
// /native-handoff signs the user in itself (straight to SSO when the app asked
|
||||
// for it). Sent to /login by the first 401 instead, the browser showed TREK's
|
||||
// own sign-in page and an SSO sign-in from the app took an extra round.
|
||||
const publicPaths = ['/login', '/register', '/forgot-password', '/reset-password', '/native-handoff']
|
||||
const publicPrefixes = ['/shared/', '/public/']
|
||||
return publicPaths.includes(pathname) || publicPrefixes.some((p) => pathname.startsWith(p))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// FE-CLIENT-INTERCEPTOR-001 to FE-CLIENT-INTERCEPTOR-012
|
||||
// FE-CLIENT-INTERCEPTOR-001 to FE-CLIENT-INTERCEPTOR-015
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { isAuthPublicPath } from '../../../src/api/client'
|
||||
|
||||
@@ -19,6 +19,10 @@ describe('FE-CLIENT-INTERCEPTOR: 401 AUTH_REQUIRED redirect allowlist', () => {
|
||||
it('FE-CLIENT-INTERCEPTOR-004: /reset-password', () => {
|
||||
expect(isAuthPublicPath('/reset-password')).toBe(true)
|
||||
})
|
||||
|
||||
it('FE-CLIENT-INTERCEPTOR-015: /native-handoff, which signs in by itself', () => {
|
||||
expect(isAuthPublicPath('/native-handoff')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('prefix-match public paths — no redirect', () => {
|
||||
|
||||
Reference in New Issue
Block a user