登录验证码接入
This commit is contained in:
1 parent
ae075bda6d
commit
f489a3553c
15 files changed
+471
-19
No files matched your search
Generated
+7
@@ -17,6 +17,7 @@
|
||||
"@capgo/capacitor-updater": "^8.51.10",
|
||||
"@ckeditor/ckeditor5-vue": "^8.2.0",
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@fingerprintjs/fingerprintjs": "^5.2.0",
|
||||
"axios": "^1.19.0",
|
||||
"ckeditor5": "^48.4.0",
|
||||
"dompurify": "^3.4.13",
|
||||
@@ -2674,6 +2675,12 @@
|
||||
"vue": "^3.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@fingerprintjs/fingerprintjs": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@fingerprintjs/fingerprintjs/-/fingerprintjs-5.2.0.tgz",
|
||||
"integrity": "sha512-j+2nInkwCQNTJcNhOjvkGM/nLRTuGJTC6xai4quqvUpjob2ssrGwBZjS7k55nOmKvge7qvJT2nS3i/IRvQSTQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@floating-ui/core": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz",
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"@capgo/capacitor-updater": "^8.51.10",
|
||||
"@ckeditor/ckeditor5-vue": "^8.2.0",
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@fingerprintjs/fingerprintjs": "^5.2.0",
|
||||
"axios": "^1.19.0",
|
||||
"ckeditor5": "^48.4.0",
|
||||
"dompurify": "^3.4.13",
|
||||
|
||||
+12
-15
@@ -20,14 +20,16 @@ const http = axios.create({
|
||||
timeout: 15000,
|
||||
})
|
||||
|
||||
function isAuthenticationRequest(url?: string) {
|
||||
return url?.startsWith('/auth/login') ||
|
||||
url?.endsWith('/auth/refresh') ||
|
||||
url?.endsWith('/auth/logout') ||
|
||||
url?.endsWith('/auth/sso/exchange') ||
|
||||
url?.endsWith('/auth/sso/bind')
|
||||
}
|
||||
|
||||
http.interceptors.request.use(async (config) => {
|
||||
const isAuthenticationRequest =
|
||||
config.url?.endsWith('/auth/login') ||
|
||||
config.url?.endsWith('/auth/refresh') ||
|
||||
config.url?.endsWith('/auth/logout') ||
|
||||
config.url?.endsWith('/auth/sso/exchange') ||
|
||||
config.url?.endsWith('/auth/sso/bind')
|
||||
if (!isAuthenticationRequest && !config.skipAuthSession) {
|
||||
if (!isAuthenticationRequest(config.url) && !config.skipAuthSession) {
|
||||
const activeToken = await refreshIfNeeded(true)
|
||||
if (activeToken) markActivity()
|
||||
}
|
||||
@@ -39,15 +41,10 @@ http.interceptors.request.use(async (config) => {
|
||||
http.interceptors.response.use(
|
||||
(response) => response,
|
||||
async (error) => {
|
||||
const isAuthenticationRequest =
|
||||
error.config?.url?.endsWith('/auth/login') ||
|
||||
error.config?.url?.endsWith('/auth/refresh') ||
|
||||
error.config?.url?.endsWith('/auth/logout') ||
|
||||
error.config?.url?.endsWith('/auth/sso/exchange') ||
|
||||
error.config?.url?.endsWith('/auth/sso/bind')
|
||||
const authenticationRequest = isAuthenticationRequest(error.config?.url)
|
||||
const retryableConfig = error.config as
|
||||
(typeof error.config & { _jiaowuRetried?: boolean }) | undefined
|
||||
if (error.response?.status === 401 && !isAuthenticationRequest && !error.config?.skipAuthSession &&
|
||||
if (error.response?.status === 401 && !authenticationRequest && !error.config?.skipAuthSession &&
|
||||
!retryableConfig?._jiaowuRetried) {
|
||||
const token = await refreshAuthSession()
|
||||
if (token && retryableConfig) {
|
||||
@@ -56,7 +53,7 @@ http.interceptors.response.use(
|
||||
return http.request(retryableConfig)
|
||||
}
|
||||
}
|
||||
if (error.response?.status === 401 && !isAuthenticationRequest && !error.config?.skipAuthSession) {
|
||||
if (error.response?.status === 401 && !authenticationRequest && !error.config?.skipAuthSession) {
|
||||
clearAuthSession()
|
||||
goLogin(location.pathname + location.search + location.hash)
|
||||
}
|
||||
|
||||
Loaded 3 of 15 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user