|
@@ -7,7 +7,7 @@ import { jwtDecode } from 'jwt-decode'
|
|
|
import MockLogin from '../Login.vue'
|
|
import MockLogin from '../Login.vue'
|
|
|
import { api } from '../../api'
|
|
import { api } from '../../api'
|
|
|
import {
|
|
import {
|
|
|
- clearOAuthTemp, consumeOAuthTransaction,
|
|
|
|
|
|
|
+ clearAuthInfo, getCachedOAuthState, clearOAuthTemp, consumeOAuthTransaction,
|
|
|
getCachedVerifier, getOAuthLoginUrl,
|
|
getCachedVerifier, getOAuthLoginUrl,
|
|
|
getToken, mockLogin, setAuthInfo
|
|
getToken, mockLogin, setAuthInfo
|
|
|
} from '../../utils/auth'
|
|
} from '../../utils/auth'
|
|
@@ -71,23 +71,23 @@ function showError(error: unknown) {
|
|
|
|
|
|
|
|
async function handleCallback(code: string, state: string | null, authError: string | null) {
|
|
async function handleCallback(code: string, state: string | null, authError: string | null) {
|
|
|
// 清理 URL 中的 OAuth 临时参数,避免刷新页面重复使用
|
|
// 清理 URL 中的 OAuth 临时参数,避免刷新页面重复使用
|
|
|
- // const query = new URLSearchParams(location.search)
|
|
|
|
|
- // for (const key of ['code', 'state', 'error', 'error_description', 'session_state', 'iss']) {
|
|
|
|
|
- // query.delete(key)
|
|
|
|
|
- // }
|
|
|
|
|
- // const remaining = query.toString()
|
|
|
|
|
- // history.replaceState(history.state, '', `${location.pathname}${remaining ? `?${remaining}` : ''}`)
|
|
|
|
|
-
|
|
|
|
|
- // sessionStorage.removeItem('oauth_no_auto_redirect')
|
|
|
|
|
- // clearAuthInfo()
|
|
|
|
|
-
|
|
|
|
|
- // const cachedState = getCachedOAuthState()
|
|
|
|
|
- // if (!state || !cachedState || state !== cachedState) {
|
|
|
|
|
- // ElMessage.warning('登录状态校验失败,准备重新发起认证')
|
|
|
|
|
- // clearOAuthTemp()
|
|
|
|
|
- // authorize()
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ const query = new URLSearchParams(location.search)
|
|
|
|
|
+ for (const key of ['code', 'state', 'error', 'error_description', 'session_state', 'iss']) {
|
|
|
|
|
+ query.delete(key)
|
|
|
|
|
+ }
|
|
|
|
|
+ const remaining = query.toString()
|
|
|
|
|
+ history.replaceState(history.state, '', `${location.pathname}${remaining ? `?${remaining}` : ''}`)
|
|
|
|
|
+
|
|
|
|
|
+ sessionStorage.removeItem('oauth_no_auto_redirect')
|
|
|
|
|
+ clearAuthInfo()
|
|
|
|
|
+
|
|
|
|
|
+ const cachedState = getCachedOAuthState()
|
|
|
|
|
+ if (!state || !cachedState || state !== cachedState) {
|
|
|
|
|
+ ElMessage.warning('登录状态校验失败,准备重新发起认证')
|
|
|
|
|
+ clearOAuthTemp()
|
|
|
|
|
+ authorize()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const codeVerifier = getCachedVerifier()
|
|
const codeVerifier = getCachedVerifier()
|
|
|
if (!codeVerifier) {
|
|
if (!codeVerifier) {
|