File tree 1 file changed +18
-6
lines changed
app/templates/client/components/auth(auth)
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,29 @@ angular.module('<%= scriptAppName %>.auth')
10
10
return ;
11
11
}
12
12
13
- let query = typeof next . authenticate === 'string' ? Auth . hasRole : Auth . isLoggedIn ;
13
+ if ( typeof next . authenticate === 'string' ) {
14
+ Auth . hasRole ( next . authenticate , _ . noop ) . then ( has => {
15
+ if ( has ) {
16
+ return ;
17
+ }
14
18
15
- query ( 1 , 2 ) . then ( good => {
16
- if ( ! good ) {
17
19
event . preventDefault ( ) ;
18
- Auth . isLoggedIn ( ) . then ( is => { < % if ( filters . ngroute ) { % >
20
+ return Auth . isLoggedIn ( ) . then ( is => { < % if ( filters . ngroute ) { % >
19
21
$location . path ( is ? '/' : '/login' ) ; < % } if ( filters . uirouter ) { % >
20
22
$state . go ( is ? 'main' : 'login' ) ; < % } % >
21
23
} ) ;
22
- }
23
- } ) ;
24
+ } )
25
+ } else {
26
+ Auth . isLoggedIn ( _ . noop ) . then ( is => {
27
+ if ( is ) {
28
+ return ;
29
+ }
30
+
31
+ event . preventDefault ( ) ; < % if ( filters . ngroute ) { % >
32
+ $location . path ( '/' ) ; < % } if ( filters . uirouter ) { % >
33
+ $state . go ( 'main' ) ; < % } % >
34
+ } ) ;
35
+ }
24
36
} ) ;
25
37
} ) ;
26
38
You can’t perform that action at this time.
0 commit comments