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

Commit 60231e3

Browse files
committed
Add t&cs check to loggedInNavGuard
In loggedInNavGuard check that user has accepted t&cs and send them to profile page if not. Checking for `requiredFieldsComplete` on the user profile won't actually check for t&cs and this is what we really want to check.
1 parent 3ba3fb6 commit 60231e3

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/dashboard/cd-dashboard.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@
8181
async created() {
8282
await this.loadProfile();
8383
84-
if (this.userProfile && this.userProfile.requiredFieldsComplete === false) {
85-
this.$router.push(`/dashboard/profile/${this.userProfile.userId}/edit`);
86-
}
87-
8884
await this.getUserDojos();
8985
this.setUserDimension();
9086
},

src/router/loggedInNavGuard.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,19 @@ import UserService from '@/users/service';
22

33
export default async function (to, from, next) {
44
const loggedInUser = (await UserService.getCurrentUser()).body;
5-
next(loggedInUser.login ? undefined : { name: 'Login', query: { referer: to.fullPath } });
5+
if (loggedInUser.login === null) {
6+
next({ name: 'Login', query: { referer: to.fullPath } });
7+
return null;
8+
}
9+
10+
if (
11+
loggedInUser.user &&
12+
loggedInUser.user.termsConditionsAccepted === false
13+
) {
14+
next({ path: `/dashboard/profile/${loggedInUser.user.id}/edit` });
15+
return null;
16+
}
17+
18+
next();
19+
return null;
620
}

0 commit comments

Comments
 (0)