Preserve destination on session-expiry login; compact the tokens table
All checks were successful
CI / backend (push) Successful in 1m20s
CI / naming (push) Successful in 1s
CI / frontend (push) Successful in 7s

The 401 interceptor (session expired) redirected to bare /login,
losing the page the user was on - the router guard already preserved
it but the expiry path bypassed the guard. The interceptor now carries
?redirect= like the guard does, and Login returns there.

The API tokens tables overflowed the card: the token column no longer
repeats the shopdb_pat_ prefix per row (short prefix shown, full form
on hover) - the token itself was already never displayed after
creation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-07-12 09:33:02 -04:00
parent 7dfbe7bf8a
commit 12da0429b0
2 changed files with 9 additions and 4 deletions

View File

@@ -28,9 +28,14 @@ api.interceptors.response.use(
const hadToken = localStorage.getItem('token')
localStorage.removeItem('token')
localStorage.removeItem('user')
// Only redirect if user was previously logged in (session expired)
// Only redirect if user was previously logged in (session expired).
// Preserve the destination so login returns the user to this page.
if (hadToken) {
window.location.href = '/login'
const here = window.location.pathname + window.location.search
const target = here && here !== '/login'
? '/login?redirect=' + encodeURIComponent(here)
: '/login'
window.location.href = target
}
}
return Promise.reject(error)

View File

@@ -35,7 +35,7 @@
<tbody>
<tr v-for="token in myTokens" :key="token.tokenid">
<td>{{ token.name }}</td>
<td><code>{{ token.displayprefix }}...</code></td>
<td><code :title="token.displayprefix + '...'">{{ token.tokenprefix }}...</code></td>
<td><span class="badge" :class="scopeBadgeClass(token)">{{ scopeSummary(token) }}</span></td>
<td>{{ formatDate(token.createddate) }}</td>
<td>{{ token.expiresat ? formatDate(token.expiresat) : 'Never' }}</td>
@@ -84,7 +84,7 @@
<tr v-for="token in allTokens" :key="token.tokenid">
<td>{{ token.username || '-' }}</td>
<td>{{ token.name }}</td>
<td><code>{{ token.displayprefix }}...</code></td>
<td><code :title="token.displayprefix + '...'">{{ token.tokenprefix }}...</code></td>
<td><span class="badge" :class="scopeBadgeClass(token)">{{ scopeSummary(token) }}</span></td>
<td>{{ token.expiresat ? formatDate(token.expiresat) : 'Never' }}</td>
<td>{{ token.lastusedat ? formatDate(token.lastusedat) : 'Never' }}</td>