Commit a1463c7a by cocomilk2012

oidc authcode login

parent c1141741
Showing with 17 additions and 28 deletions
......@@ -23,33 +23,21 @@ const router = new VueRouter({
component: () => import("@/views/test.vue")
}
],
scrollBehavior(to, from, savedPosition) {
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
})
//router.beforeEach(vuexOidcCreateRouterMiddleware(store));
router.beforeEach((to, from, next) => {
store.dispatch("getOidcUser").then(user => {
if (user) {
console.log('3');
console.log('user=', user);
const authcode = to.query.authcode;
const params = { to, authcode }
store.dispatch('oidcCheckAccess', params).then(function (hasAccess) {
const hasToken = localStorage.getItem("token") ? true : false;
if (hasAccess && hasToken) {
next();
}
else {
console.log('4');
const authCode = "8f933f0af8d541188a5161218a4650db";//to.query.authcode;
let args = { options: { extraQueryParams: { authcode: authCode } } };
store.dispatch('authenticateOidc', args);
}
}).catch(err => {
console.log(err);
const authCode = "8f933f0af8d541188a5161218a4650db";
let args = { options: { extraQueryParams: { authcode: authCode } } };
store.dispatch('authenticateOidc', args);
});
})
......
......@@ -60,16 +60,17 @@ export default {
mounted() {
this.oidcSignInCallback()
.then(redirectPath => {
// this.getOidcUser()
// .then(user => {
// let urlsearch = redirectPath.split("?")[1];
// let appid = this.getQueryString(urlsearch, "appid");
// this.getToken(user.access_token, appid, redirectPath);
// })
// .catch(err => {
// console.log("err=", err);
// });
this.$router.push(redirectPath);
console.log(2);
this.getOidcUser()
.then(user => {
let urlsearch = redirectPath.split("?")[1];
let appid = this.getQueryString(urlsearch, "appid");
this.getToken(user.access_token, appid, redirectPath);
})
.catch(err => {
console.log("err=", err);
});
//this.$router.push(redirectPath);
})
.catch(err => {
console.error(err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment