From 939307af339f4b674b61180618d23ca35b4dccd3 Mon Sep 17 00:00:00 2001 From: xuechunyuan <17853500702@163.com> Date: Wed, 24 May 2023 16:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.js | 3 ++- src/page/login/index.vue | 9 +++++---- src/permission.js | 3 +++ src/store/modules/user.js | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/api/user.js b/src/api/user.js index 254979a..12fb0f7 100644 --- a/src/api/user.js +++ b/src/api/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, } diff --git a/src/page/login/index.vue b/src/page/login/index.vue index b48a631..022d66b 100644 --- a/src/page/login/index.vue +++ b/src/page/login/index.vue @@ -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: '确定', diff --git a/src/permission.js b/src/permission.js index ad79c37..ac783ce 100644 --- a/src/permission.js +++ b/src/permission.js @@ -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') } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 39e580e..99f1eac 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -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'){