重定向逻辑优化

main
xuechunyuan 3 years ago
parent db37e0aeba
commit 939307af33
  1. 3
      src/api/user.js
  2. 9
      src/page/login/index.vue
  3. 3
      src/permission.js
  4. 2
      src/store/modules/user.js

@ -51,7 +51,7 @@ export const loginBySocial = (tenantId, source, code, state) => request({
// redirect_uri: website.redirectUri,
// }
// })
export const loginBySso = (SSOToken, grantType) => request({
export const loginBySso = (SSOToken, grantType, fallbackUrl) => request({
url: '/api/blade-auth/oauth/token',
method: 'post',
headers: {
@ -61,6 +61,7 @@ export const loginBySso = (SSOToken, grantType) => request({
tenantId: '000000',
SSOToken,
grant_type: grantType,
fallbackUrl,
scope: "all",
redirect_uri: website.redirectUri,
}

@ -38,8 +38,8 @@ export default {
}else{
this.loading = true;
this.$store
.dispatch("LoginBySso", {SSOToken: ssotoken,grantType:'yawei'})
.then((res) => {
.dispatch("LoginBySso", {SSOToken: ssotoken,grantType:'yawei',fallbackUrl: ssotoken ? '' : window.location.href})
.then(() => {
this.loading = false;
console.log('=============登录成功')
this.$router.replace({ path: this.tagWel.value });
@ -47,8 +47,9 @@ export default {
this.loading = false;
console.log('err=======res',err)
if(err.error == 'invalid_request') {
let url = err.error_description+'?SSOToken=' + encodeURIComponent(window.location);
window.location.href = url;//
// let url = err.error_description+'?SSOToken=' + encodeURIComponent(window.location);
window.location.href = err.error_description;//
// window.location.href = 'http://jhoa.qd.gov.cn/Keeper.aspx?SSOToken=PSOSite%24TjZXxbcic5BDwCphjqib%2BVEWXFe1JX5N1VBWsX%2FNAapJ5MHEKOyR0Jf24C09C1NdofaFCYjfNvA%3D';
}else if(err.error == 'invalid_grant') {
this.$confirm(err.error_description, '提示', {
confirmButtonText: '确定',

@ -53,9 +53,12 @@ router.beforeEach((to, from, next) => {
}
}
} else {
console.log('nologin===permission===========',to.path)
//判断是否需要认证,没有登录访问去登录页
if (meta.isAuth === false) {
next()
} else if(to.path == '/wel/index') {
next('/login')
} else {
next('/newlogin')
}

@ -106,7 +106,7 @@ const user = {
//根据单点信息登录
LoginBySso({commit}, userInfo) {
return new Promise((resolve, reject) => {
loginBySso(userInfo.SSOToken, userInfo.grantType).then(res => {
loginBySso(userInfo.SSOToken, userInfo.grantType, userInfo.fallbackUrl).then(res => {
console.log('loginBySso=======res',res)
// const data = res.data;
if(res.error != 'invalid_request' && res.error != 'invalid_grant'){

Loading…
Cancel
Save