Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 79a6218

Browse files
authored
Merge pull request #279 from CoderDojo/rpi-login
Redirect login to rpi profile if local storage flag on
2 parents a2c34d0 + 1274b80 commit 79a6218

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/router/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import CDFManageUsers from '@/users/cdf-manage';
1818
import ManageRequestToJoin from '@/dojos/manage-request-to-join';
1919
import loggedInNavGuard from './loggedInNavGuard';
2020
import loggedInCDFNavGuard from './loggedInCDFNavGuard';
21+
import profileAuthRedirect from './profileAuthRedirect';
2122
import orderExistsNavGuard from './orderExistsNavGuard';
2223
import ticketingAdminNavGuard from './ticketingAdminNavGuard';
2324

@@ -108,6 +109,7 @@ const router = new Router({
108109
path: '/login',
109110
name: 'Login',
110111
component: Login,
112+
beforeEnter: profileAuthRedirect,
111113
},
112114
{
113115
path: '/home',

src/router/profileAuthRedirect.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default function (to, from, next) {
2+
const profileAuthFlag = window.localStorage.getItem('profileAuth');
3+
4+
if (profileAuthFlag === 'true') {
5+
const profileAuthPath = '/rpi/login';
6+
const params = new URLSearchParams();
7+
params.append('origin', window.location.pathname);
8+
params.append('redirect', to.fullPath);
9+
window.location.href = `${profileAuthPath}?${params}`;
10+
} else {
11+
next();
12+
}
13+
}

0 commit comments

Comments
 (0)