修复前端登录权限边界问题

This commit is contained in:
andy
2026-07-10 09:35:47 +08:00
parent e49b2ccc1d
commit 25efcccf72
11 changed files with 282 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { fetchCurrentAuth, loginAuth, logoutAuth } from '@/services/authService'
import { clearStoredAccessToken, getStoredAccessToken, setStoredAccessToken } from '@/services/authSession'
import { isAuthUnauthorizedError } from '@/services/httpClient'
import type {
AuthHotelResult,
AuthLoginRequest,
@@ -78,9 +79,14 @@ export const useAuthStore = defineStore('auth', {
this.applyAuthContext(result)
this.restoreAttempted = true
return true
} catch {
this.clearAuth()
this.restoreAttempted = true
} catch (error) {
if (isAuthUnauthorizedError(error)) {
this.clearAuth()
this.restoreAttempted = true
} else {
this.accessToken = token
this.restoreAttempted = false
}
return false
} finally {
this.restoring = false