Commit a1463c7a by cocomilk2012

oidc authcode login

parent c1141741
Showing with 17 additions and 28 deletions
...@@ -23,33 +23,21 @@ const router = new VueRouter({ ...@@ -23,33 +23,21 @@ const router = new VueRouter({
component: () => import("@/views/test.vue") component: () => import("@/views/test.vue")
} }
], ],
scrollBehavior(to, from, savedPosition) { scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 } return { x: 0, y: 0 }
} }
}) })
//router.beforeEach(vuexOidcCreateRouterMiddleware(store)); //router.beforeEach(vuexOidcCreateRouterMiddleware(store));
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
store.dispatch("getOidcUser").then(user => { const authcode = to.query.authcode;
if (user) { const params = { to, authcode }
console.log('3'); store.dispatch('oidcCheckAccess', params).then(function (hasAccess) {
console.log('user=', user); const hasToken = localStorage.getItem("token") ? true : false;
if (hasAccess && hasToken) {
next(); 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 { ...@@ -60,16 +60,17 @@ export default {
mounted() { mounted() {
this.oidcSignInCallback() this.oidcSignInCallback()
.then(redirectPath => { .then(redirectPath => {
// this.getOidcUser() console.log(2);
// .then(user => { this.getOidcUser()
// let urlsearch = redirectPath.split("?")[1]; .then(user => {
// let appid = this.getQueryString(urlsearch, "appid"); let urlsearch = redirectPath.split("?")[1];
// this.getToken(user.access_token, appid, redirectPath); let appid = this.getQueryString(urlsearch, "appid");
// }) this.getToken(user.access_token, appid, redirectPath);
// .catch(err => { })
// console.log("err=", err); .catch(err => {
// }); console.log("err=", err);
this.$router.push(redirectPath); });
//this.$router.push(redirectPath);
}) })
.catch(err => { .catch(err => {
console.error(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