Handle redirect after successful login in frontend
This commit is contained in:
parent
47a5266752
commit
8ac5ab67e9
|
|
@ -6,7 +6,7 @@ import VueVimeoPlayer from 'vue-vimeo-player';
|
|||
import apolloClientFactory from './graphql/client';
|
||||
import VueApollo from 'vue-apollo';
|
||||
import App from './App';
|
||||
import router from './router';
|
||||
import {router, postLoginRederictUrlKey} from './router';
|
||||
import store from '@/store/index';
|
||||
import VueScrollTo from 'vue-scrollto';
|
||||
import {Validator, install as VeeValidate} from 'vee-validate/dist/vee-validate.minimal.esm.js';
|
||||
|
|
@ -161,7 +161,13 @@ router.beforeEach(async (to, from, next) => {
|
|||
}
|
||||
|
||||
if (unauthorizedAccess(to)) {
|
||||
const redirectUrl = `/hello?redirect=${to.path}`;
|
||||
const postLoginRedirectionUrl = to.path;
|
||||
const redirectUrl = `/api/oauth/login/`;
|
||||
|
||||
if (window.localStorage) {
|
||||
localStorage.setItem(postLoginRederictUrlKey, postLoginRedirectionUrl);
|
||||
}
|
||||
|
||||
next(redirectUrl);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import roomRoutes from './room.routes';
|
|||
import store from '@/store/index';
|
||||
import {LAYOUT_SIMPLE} from '@/router/core.constants';
|
||||
|
||||
const postLoginRederictUrlKey = 'postLoginRedirectionUrl';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
|
|
@ -104,6 +106,12 @@ const routes = [
|
|||
return '/verify-email';
|
||||
case 'no_valid_license':
|
||||
return '/verify-email';
|
||||
case 'success':
|
||||
if (window.localStorage && localStorage.getItem(postLoginRederictUrlKey)) {
|
||||
const redirectUrl = localStorage.getItem(postLoginRederictUrlKey);
|
||||
localStorage.removeItem(postLoginRederictUrlKey);
|
||||
return redirectUrl;
|
||||
}
|
||||
default:
|
||||
return '/unknown';
|
||||
}
|
||||
|
|
@ -137,4 +145,5 @@ router.afterEach((to, from) => {
|
|||
store.commit('setEditModule', false);
|
||||
store.dispatch('showMobileNavigation', false);
|
||||
});
|
||||
export default router;
|
||||
|
||||
export {router, postLoginRederictUrlKey};
|
||||
|
|
|
|||
Loading…
Reference in New Issue