重定向逻辑优化

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

@ -38,8 +38,8 @@ export default {
}else{ }else{
this.loading = true; this.loading = true;
this.$store this.$store
.dispatch("LoginBySso", {SSOToken: ssotoken,grantType:'yawei'}) .dispatch("LoginBySso", {SSOToken: ssotoken,grantType:'yawei',fallbackUrl: ssotoken ? '' : window.location.href})
.then((res) => { .then(() => {
this.loading = false; this.loading = false;
console.log('=============登录成功') console.log('=============登录成功')
this.$router.replace({ path: this.tagWel.value }); this.$router.replace({ path: this.tagWel.value });
@ -47,8 +47,9 @@ export default {
this.loading = false; this.loading = false;
console.log('err=======res',err) console.log('err=======res',err)
if(err.error == 'invalid_request') { if(err.error == 'invalid_request') {
let url = err.error_description+'?SSOToken=' + encodeURIComponent(window.location); // let url = err.error_description+'?SSOToken=' + encodeURIComponent(window.location);
window.location.href = url;// 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') { }else if(err.error == 'invalid_grant') {
this.$confirm(err.error_description, '提示', { this.$confirm(err.error_description, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',

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

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

Loading…
Cancel
Save