mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 01:06:28 +08:00
fix(pm): preserve redirect when sending logged-out users to login
Unauthenticated /pm visits pushed to /login without a redirect query, so after sign-in they landed on the classroom fallback instead of returning to /pm. Pass route.fullPath as ?redirect= so the bridge link (incl. ?token=…) survives the login round-trip. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2497,12 +2497,19 @@ const scheduleAirportDataRefresh = () => {
|
||||
}, delay)
|
||||
}
|
||||
|
||||
// Send unauthenticated visitors to login while preserving where they were
|
||||
// headed (e.g. /pm?token=… so the bridge link survives the round-trip),
|
||||
// instead of dropping them on the classroom fallback after sign-in.
|
||||
const redirectToLogin = () => {
|
||||
router.push({ path: '/login', query: { redirect: route.fullPath } })
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
if (!auth.accessToken) {
|
||||
const refreshed = await auth.tryRefresh()
|
||||
if (!refreshed) {
|
||||
router.push('/login')
|
||||
redirectToLogin()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -2510,7 +2517,7 @@ onMounted(async () => {
|
||||
if (!auth.user) {
|
||||
await auth.fetchUser().catch((err) => {
|
||||
console.error('Session initialisation failed', err)
|
||||
router.push('/login')
|
||||
redirectToLogin()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2568,7 +2575,7 @@ watch(
|
||||
(token) => {
|
||||
if (!token) {
|
||||
persistSelectedPlan(null)
|
||||
router.push('/login')
|
||||
redirectToLogin()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user