v2026.10.1: keep login redirect, show wrong-password error

The axios 401 interceptor treated failed auth calls (the guard's own
/api/auth/refresh, a wrong-password /api/auth/login) as an expired session
and hard-navigated to a bare /login. That dropped the router guard's
?redirect= and reloaded the login page before its error could show.

- Skip auto-refresh for login/register/refresh
- On a real mid-use expiry, redirect to /login?redirect=<current path>
- LoginView only follows in-app redirect paths

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
derekcandClaude Opus 5.5 committed 2026-10-12 23:10:04 -07:00
1 parent 954161ba8f
commit 3460fff8ff
5 files changed
+26 -8

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "homeschool-frontend",
"version": "2026.10.0",
"version": "2026.10.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "homeschool-frontend",
"version": "2026.10.0",
"version": "2026.10.1",
"dependencies": {
"@vue/devtools-api": "8.2.1",
"axios": "1.20.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "homeschool-frontend",
"version": "2026.10.0",
"version": "2026.10.1",
"private": true,
"type": "module",
"scripts": {
+7 -2
View File
@@ -17,12 +17,14 @@ api.interceptors.request.use((config) => {
// Auto-refresh on 401
let refreshing = false
let waitQueue = []
// These report their own 401s (wrong password, expired refresh cookie); refreshing on them would hide the error
const NO_REFRESH = ['/api/auth/login', '/api/auth/register', '/api/auth/refresh']
api.interceptors.response.use(
(res) => res,
async (error) => {
const original = error.config
if (error.response?.status === 401 && !original._retry) {
if (error.response?.status === 401 && !original._retry && !NO_REFRESH.includes(original.url)) {
if (refreshing) {
return new Promise((resolve, reject) => {
waitQueue.push({ resolve, reject })
@@ -43,7 +45,10 @@ api.interceptors.response.use(
waitQueue.forEach(({ reject }) => reject())
waitQueue = []
localStorage.removeItem('access_token')
window.location.href = '/login'
const { pathname, search } = window.location
window.location.href = pathname === '/login'
? '/login'
: `/login?redirect=${encodeURIComponent(pathname + search)}`
} finally {
refreshing = false
}
+4 -2
View File
@@ -57,8 +57,10 @@ async function submit() {
} else {
await auth.register(form.value.email, form.value.password, form.value.fullName)
}
const redirect = route.query.redirect || '/dashboard'
router.push(redirect)
// Only follow in-app paths ("//host" would be protocol-relative)
const redirect = route.query.redirect
const safe = typeof redirect === 'string' && redirect.startsWith('/') && !redirect.startsWith('//')
router.push(safe ? redirect : '/dashboard')
} catch (e) {
error.value = e.response?.data?.detail || 'Something went wrong'
} finally {