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

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

No files matched your search

+9 -3
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