File tree 1 file changed +5
-25
lines changed
1 file changed +5
-25
lines changed Original file line number Diff line number Diff line change 13
13
$scope . modalRegister = stateService . get ( 'modalRegister' ) ;
14
14
} ) ;
15
15
16
- //this execute after every page refresh
17
16
$localForage . getItem ( 'authorization' )
18
- . then ( function ( authData ) {
19
- if ( authData ) {
20
- $scope . auth = true ;
21
- } else {
22
- $scope . auth = false ;
23
- }
24
- } , function ( ) {
25
- console . log ( "error with getting authorization localForage after refresh" ) ;
26
- }
27
- ) ;
17
+ . then ( ( authData ) => { $scope . auth = authData } ) ;
28
18
29
- //this execute after custom event emitted after success login response
30
- $rootScope . $on ( 'authChange' , function ( event ) {
19
+ $rootScope . $on ( 'user::auth' , ( ) => {
31
20
$localForage . getItem ( 'authorization' )
32
- . then ( function ( authData ) {
33
- if ( authData ) {
34
- $scope . auth = true ;
35
- console . log ( 'logged' ) ;
36
- } else {
37
- $scope . auth = false ;
38
- $location . path ( '/' ) ;
39
- }
40
- } , function ( ) {
41
- console . log ( "error with getting authorization localForage on event" ) ;
42
- }
43
- ) ;
21
+ . then ( ( authData ) => {
22
+ $scope . auth = authData ;
23
+ } ) ;
44
24
} ) ;
45
25
}
46
26
You can’t perform that action at this time.
0 commit comments