@@ -57,7 +57,7 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
57
57
*/
58
58
logout ( ) {
59
59
$cookies . remove ( 'token' ) ;
60
- currentUser = new User ( ) ;
60
+ currentUser = new _User ( ) ;
61
61
} ,
62
62
63
63
/**
@@ -103,7 +103,7 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
103
103
* @return {Promise }
104
104
*/
105
105
getCurrentUser ( callback ?: Function ) {
106
- var value = currentUser . hasOwnProperty ( '$promise' )
106
+ var value = _ . get ( currentUser , '$promise' )
107
107
? currentUser . $promise
108
108
: currentUser ;
109
109
@@ -135,7 +135,8 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
135
135
isLoggedIn ( callback ?: Function ) {
136
136
return Auth . getCurrentUser ( undefined )
137
137
. then ( user => {
138
- var is = user . hasOwnProperty ( 'role' ) ;
138
+ let is = _ . get ( user , 'role' ) ;
139
+
139
140
safeCb ( callback ) ( is ) ;
140
141
return is ;
141
142
} ) ;
@@ -147,7 +148,7 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
147
148
* @return {Bool }
148
149
*/
149
150
isLoggedInSync ( ) {
150
- return currentUser . hasOwnProperty ( 'role' ) ;
151
+ return ! ! _ . get ( currentUser , 'role' ) ;
151
152
} ,
152
153
153
154
/**
@@ -160,9 +161,7 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
160
161
hasRole ( role , callback ?: Function ) {
161
162
return Auth . getCurrentUser ( undefined )
162
163
. then ( user => {
163
- var has = user . hasOwnProperty ( 'role' )
164
- ? hasRole ( user . role , role )
165
- : false ;
164
+ let has = hasRole ( _ . get ( user , 'role' ) , role ) ;
166
165
167
166
safeCb ( callback ) ( has ) ;
168
167
return has ;
@@ -176,7 +175,7 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
176
175
* @return {Bool }
177
176
*/
178
177
hasRoleSync ( role ) {
179
- return hasRole ( currentUser . role , role ) ;
178
+ return hasRole ( _ . get ( currentUser , ' role' ) , role ) ;
180
179
} ,
181
180
182
181
/**
0 commit comments