Auth-Redirect vor Bootstrap verhindern

This commit is contained in:
2026-06-02 12:03:34 +02:00
parent 4aea8b94c3
commit 78f9bd3f7a
2 changed files with 17 additions and 5 deletions

View File

@@ -34,6 +34,18 @@ export const useAuthStore = defineStore("auth", {
return useCookie<string | null>("token", { path: "/" })
},
getStoredToken() {
const rootToken = this.tokenCookie().value
if (rootToken || !process.client) return rootToken
const tokenCookie = document.cookie
.split(";")
.map((part) => part.trim())
.find((part) => part.startsWith("token="))
return tokenCookie ? decodeURIComponent(tokenCookie.slice("token=".length)) : null
},
clearScopedTokenCookies() {
if (!process.client) return
@@ -113,7 +125,7 @@ export const useAuthStore = defineStore("auth", {
scheduleSessionTimers(token?: string | null) {
if (!process.client) return
const tokenToUse = token || this.tokenCookie().value
const tokenToUse = token || this.getStoredToken()
this.clearSessionTimers()
this.sessionWarningVisible = false
@@ -173,7 +185,7 @@ export const useAuthStore = defineStore("auth", {
console.log("Auth initStore")
// 1. Check: Haben wir überhaupt ein Token?
const token = this.tokenCookie().value
const token = this.getStoredToken()
if (!token) {
// Kein Token -> Wir sind fertig, User ist Gast.
@@ -298,7 +310,7 @@ export const useAuthStore = defineStore("auth", {
const tempStore = useTempStore()
// Token aus Argument oder Cookie holen
const tokenToUse = jwt || this.tokenCookie().value
const tokenToUse = jwt || this.getStoredToken()
if (!tokenToUse) {
const wasSessionExpired = this.sessionExpired