@le5le/auth-token
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@le5le/auth-token", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "le5le Single sign-on solution", | ||
@@ -14,6 +14,2 @@ "main": "index.js", | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"keywords": [ | ||
@@ -20,0 +16,0 @@ "le5le", |
112
src/token.js
@@ -50,3 +50,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
export function axiosResponse(axios, MessagePlugin) { | ||
export function axiosResponse(axios) { | ||
axios.interceptors.response.use(function (response) { | ||
@@ -57,12 +57,12 @@ var _a, _b; | ||
} | ||
if (response && response.data && response.data.error) { | ||
MessagePlugin.error(response.data.error); | ||
return; | ||
} | ||
if (response) { | ||
if (response.status == undefined) { | ||
return response; | ||
} | ||
return response.data; | ||
} | ||
// if (response && response.data && response.data.error) { | ||
// MessagePlugin.error(response.data.error); | ||
// return; | ||
// } | ||
// if (response) { | ||
// if (response.status == undefined) { | ||
// return response; | ||
// } | ||
// return response.data; | ||
// } | ||
return; | ||
@@ -74,49 +74,53 @@ }, function (error) { | ||
if (error && error.response) { | ||
if (error.response.config.url === '/api/account/profile' || | ||
error.response.data.error === '此为付费数据,请购买后访问') { | ||
if (error.response.config.url.indexOf('/api/account/profile') !== -1) { | ||
_deleteToken(); | ||
} | ||
return; | ||
// if ( | ||
// error.response.config.url === '/api/account/profile' || | ||
// error.response.data.error === '此为付费数据,请购买后访问' | ||
// ) { | ||
if (error.response.config.url.indexOf('/api/account/profile') !== -1) { | ||
_deleteToken(); | ||
} | ||
// return; | ||
// } | ||
if (error.response.config.url.indexOf('/api/sso/profile') !== -1) { | ||
deleteSSOToken(); | ||
} | ||
if (error.response.status !== 401 && | ||
error.response && | ||
error.response.data && | ||
error.response.data.error) { | ||
MessagePlugin.error(error.response.data.error); | ||
return; | ||
} | ||
switch (error.response.status) { | ||
case 401: | ||
if (error.response.config.url.indexOf('/api/account/profile') !== -1) { | ||
_deleteToken(); | ||
} | ||
if (error.response.config.url === '/api/account/statistics') { | ||
break; | ||
} | ||
sessionStorage.setItem('cb', encodeURIComponent(location.href)); | ||
MessagePlugin.error('请先登录!'); | ||
// router.replace({ path: '/login' }); | ||
break; | ||
case 403: | ||
MessagePlugin.error('请求错误,不合法的请求!'); | ||
break; | ||
case 404: | ||
if (error.response.config.url.indexOf('/data/') !== 0) { | ||
MessagePlugin.error('访问数据不存在,请检查后重试!'); | ||
} | ||
break; | ||
case 500: | ||
MessagePlugin.error('请求服务错误,请稍后重试!'); | ||
break; | ||
case 504: | ||
MessagePlugin.error('网络超时,请检测你的网络!'); | ||
break; | ||
default: | ||
MessagePlugin.error('未知网络错误!'); | ||
break; | ||
} | ||
// if ( | ||
// error.response.status !== 401 && | ||
// error.response && | ||
// error.response.data && | ||
// error.response.data.error | ||
// ) { | ||
// MessagePlugin.error(error.response.data.error); | ||
// return; | ||
// } | ||
// switch (error.response.status) { | ||
// case 401: | ||
// if(error.response.config.url.indexOf('/api/account/profile')!==-1){ | ||
// _deleteToken(); | ||
// } | ||
// if (error.response.config.url==='/api/account/statistics') { | ||
// break; | ||
// } | ||
// sessionStorage.setItem('cb', encodeURIComponent(location.href)); | ||
// MessagePlugin.error('请先登录!'); | ||
// // router.replace({ path: '/login' }); | ||
// break; | ||
// case 403: | ||
// MessagePlugin.error('请求错误,不合法的请求!'); | ||
// break; | ||
// case 404: | ||
// if (error.response.config.url.indexOf('/data/') !== 0) { | ||
// MessagePlugin.error('访问数据不存在,请检查后重试!'); | ||
// } | ||
// break; | ||
// case 500: | ||
// MessagePlugin.error('请求服务错误,请稍后重试!'); | ||
// break; | ||
// case 504: | ||
// MessagePlugin.error('网络超时,请检测你的网络!'); | ||
// break; | ||
// default: | ||
// MessagePlugin.error('未知网络错误!'); | ||
// break; | ||
// } | ||
} | ||
@@ -123,0 +127,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331
13437