@@ -8,9 +8,27 @@ import AccountVerified from '../views/auth/AccountVerified.vue';
88import AccountVerifiedError from '../views/auth/AccountVerifiedError.vue' ;
99import ResetPassword from '../views/auth/ResetPassword.vue' ;
1010import ResetPasswordError from '../views/auth/ResetPasswordError.vue' ;
11+ import Onboarding from '../views/app/Onboarding.vue' ;
12+ import store from '../store/index' ;
1113
1214Vue . use ( VueRouter ) ;
1315
16+ function loggedInRedirectBrowse ( to , from , next ) {
17+ if ( store . getters . getLoggedInUser ) {
18+ next ( '/browse' ) ;
19+ } else {
20+ next ( ) ;
21+ }
22+ }
23+
24+ function notLoggedInRedirectLogin ( to , from , next ) {
25+ if ( store . getters . getLoggedInUser ) {
26+ next ( ) ;
27+ } else {
28+ next ( '/accounts/signin' ) ;
29+ }
30+ }
31+
1432const routes = [
1533 {
1634 path : '/' ,
@@ -21,36 +39,49 @@ const routes = [
2139 path : '/accounts/signup' ,
2240 name : 'SignUp' ,
2341 component : SignUp ,
42+ beforeEnter : loggedInRedirectBrowse ,
2443 } ,
2544 {
2645 path : '/accounts/signin' ,
2746 name : 'SignIn' ,
2847 component : SignIn ,
48+ beforeEnter : loggedInRedirectBrowse ,
2949 } ,
3050 {
3151 path : '/accounts/password/forgot' ,
3252 name : 'ForgotPassword' ,
3353 component : ForgotPassword ,
54+ beforeEnter : loggedInRedirectBrowse ,
3455 } ,
3556 {
3657 path : '/accounts/password/reset' ,
3758 name : 'ResetPassword' ,
3859 component : ResetPassword ,
60+ beforeEnter : loggedInRedirectBrowse ,
3961 } ,
4062 {
4163 path : '/accounts/password/reseterror' ,
4264 name : 'ResetPasswordError' ,
4365 component : ResetPasswordError ,
66+ beforeEnter : loggedInRedirectBrowse ,
4467 } ,
4568 {
4669 path : '/accounts/verify' ,
4770 name : 'AccountVerified' ,
4871 component : AccountVerified ,
72+ beforeEnter : loggedInRedirectBrowse ,
4973 } ,
5074 {
5175 path : '/accounts/verify/error' ,
5276 name : 'AccountVerifiedError' ,
5377 component : AccountVerifiedError ,
78+ beforeEnter : loggedInRedirectBrowse ,
79+ } ,
80+ {
81+ path : '/onboarding' ,
82+ name : 'Onboarding' ,
83+ component : Onboarding ,
84+ beforeEnter : notLoggedInRedirectLogin ,
5485 } ,
5586] ;
5687
0 commit comments