This repository was archived by the owner on Oct 5, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Original file line number Diff line number Diff line change 3838
3939 function getAuthenticatedStatus ( ) {
4040 if ( _isAuthenticated !== undefined ) {
41- return _isAuthenticated ;
41+ return $q . resolve ( _isAuthenticated ) ;
4242 }
4343
4444 return $http . get ( '/api/user/status' , { } ) . then ( function ( response ) {
120120 'params' : JSON . stringify ( ( _toStateParams || $stateParams ) )
121121 } ) . then ( function ( ) {
122122 d . reject ( ) ;
123+ } , function ( error ) {
124+ throw error ;
123125 } ) ;
124126 }
125127 return d . promise ;
173175 }
174176
175177 if ( routeIsProtected ( next . name ) ) {
176- var auth = service . getAuthenticatedStatus ( ) ;
177-
178- if ( angular . isFunction ( auth . then ) ) {
179- auth . then ( function ( ) {
180- if ( ! service . isAuthenticated ( ) ) {
181- //this does NOT block requests in a timely fashion...
182- blockRoute ( event , next , nextParams ) ;
183- }
184- } ) ;
185- }
186- else {
187- if ( ! auth ) {
178+ service . getAuthenticatedStatus ( ) . then ( function ( ) {
179+ if ( ! service . isAuthenticated ( ) ) {
180+ //this does NOT block requests in a timely fashion...
188181 blockRoute ( event , next , nextParams ) ;
189182 }
190- }
183+ } ) ;
191184
192185 }
193186 } ) ;
Original file line number Diff line number Diff line change 44 angular . module ( 'app.user' )
55 . factory ( 'userService' , UserService ) ;
66
7- UserService . $inject = [ '$rootScope' , 'loginService' ] ;
8- function UserService ( $rootScope , loginService ) {
7+ UserService . $inject = [ '$rootScope' , '$q' , ' loginService'] ;
8+ function UserService ( $rootScope , $q , loginService ) {
99 var _currentUser = null ;
1010
1111 function currentUser ( ) {
1414
1515 function getUser ( ) {
1616 if ( _currentUser ) {
17- return _currentUser ;
17+ return $q . resolve ( _currentUser ) ;
1818 }
1919
2020 return loginService . getAuthenticatedStatus ( ) . then ( currentUser ) ;
You can’t perform that action at this time.
0 commit comments