Preserve destination on session-expiry login; compact the tokens table
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:
@@ -28,9 +28,14 @@ api.interceptors.response.use(
|
|||||||
const hadToken = localStorage.getItem('token')
|
const hadToken = localStorage.getItem('token')
|
||||||
localStorage.removeItem('token')
|
localStorage.removeItem('token')
|
||||||
localStorage.removeItem('user')
|
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) {
|
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)
|
return Promise.reject(error)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="token in myTokens" :key="token.tokenid">
|
<tr v-for="token in myTokens" :key="token.tokenid">
|
||||||
<td>{{ token.name }}</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><span class="badge" :class="scopeBadgeClass(token)">{{ scopeSummary(token) }}</span></td>
|
||||||
<td>{{ formatDate(token.createddate) }}</td>
|
<td>{{ formatDate(token.createddate) }}</td>
|
||||||
<td>{{ token.expiresat ? formatDate(token.expiresat) : 'Never' }}</td>
|
<td>{{ token.expiresat ? formatDate(token.expiresat) : 'Never' }}</td>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
<tr v-for="token in allTokens" :key="token.tokenid">
|
<tr v-for="token in allTokens" :key="token.tokenid">
|
||||||
<td>{{ token.username || '-' }}</td>
|
<td>{{ token.username || '-' }}</td>
|
||||||
<td>{{ token.name }}</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><span class="badge" :class="scopeBadgeClass(token)">{{ scopeSummary(token) }}</span></td>
|
||||||
<td>{{ token.expiresat ? formatDate(token.expiresat) : 'Never' }}</td>
|
<td>{{ token.expiresat ? formatDate(token.expiresat) : 'Never' }}</td>
|
||||||
<td>{{ token.lastusedat ? formatDate(token.lastusedat) : 'Never' }}</td>
|
<td>{{ token.lastusedat ? formatDate(token.lastusedat) : 'Never' }}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user