修复前端登录权限边界问题
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user