File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 44import Vue from 'vue' ;
55import Router from 'vue-router' ;
66import store from '@/modules/_app/app.store' ;
7+ import config from '@/config' ;
78
89import home from '@/modules/home/router/home.router' ;
910import auth from '@/modules/auth/router/auth.router' ;
@@ -29,9 +30,12 @@ const router = new Router({
2930router . beforeEach ( ( to , from , next ) => {
3031 // meta
3132 document . title = to . name ;
33+ const userRoles = localStorage . getItem ( `${ config . cookie . prefix } UserRoles` )
34+ ? localStorage . getItem ( `${ config . cookie . prefix } UserRoles` ) . split ( ',' )
35+ : [ ] ;
3236 // secu
33- if ( to . matched . some ( ( record ) => record . meta . requiresAuth ) ) {
34- if ( store . getters . isLoggedIn ) {
37+ if ( to . matched . some ( ( record ) => record . meta . roles ) ) {
38+ if ( store . getters . isLoggedIn && to . meta . roles . some ( ( r ) => userRoles . includes ( r ) ) ) {
3539 next ( ) ;
3640 return ;
3741 }
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ export default {
169169 signout () {
170170 this .$store .dispatch (' signout' ).then (() => {
171171 this .$store .dispatch (' refreshNav' );
172- if (this .$route .path !== ' /' ) this .$router .push (' /home ' );
172+ if (this .$route .path !== ' /' ) this .$router .push (' /' );
173173 });
174174 },
175175 },
Original file line number Diff line number Diff line change @@ -120,10 +120,10 @@ export default {
120120 };
121121 },
122122 computed: {
123- ... mapGetters ([' subscription ' ]),
123+ ... mapGetters ([' homeSubscription ' ]),
124124 email: {
125125 get () {
126- return this .subscription .email ;
126+ return this .homeSubscription .email ;
127127 },
128128 set (email ) {
129129 this .save = true ;
@@ -136,9 +136,9 @@ export default {
136136 return ` ${ this .config .home .temporalBackground } /${ ` 0${ new Date ().getHours ()} ` .slice (- 2 )} .jpg` ;
137137 },
138138 createSubscription () {
139- if (this .rules .email (this .subscription .email )) {
139+ if (this .rules .email (this .homeSubscription .email )) {
140140 this .$store
141- .dispatch (' createSubscription' , this .subscription )
141+ .dispatch (' createSubscription' , this .homeSubscription )
142142 .catch ((err ) => console .log (err));
143143 }
144144 },
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ const whitelists = ['email', 'news'];
1717const getters = {
1818 contents : ( state ) => state . contents ,
1919 news : ( state ) => state . news ,
20- subscription : ( state ) => state . subscription ,
20+ homeSubscription : ( state ) => state . subscription ,
2121 contact : ( state ) => state . contact ,
2222 statistics : ( state ) => state . statistics ,
2323} ;
You can’t perform that action at this time.
0 commit comments