@@ -112,6 +112,15 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
112
112
} ) ;
113
113
} ,
114
114
115
+ /**
116
+ * Gets all available info on a user
117
+ *
118
+ * @return {Object }
119
+ */
120
+ getCurrentUserSync ( ) {
121
+ return currentUser ;
122
+ } ,
123
+
115
124
/**
116
125
* Check if a user is logged in
117
126
* (synchronous|asynchronous)
@@ -132,6 +141,15 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
132
141
} ) ;
133
142
} ,
134
143
144
+ /**
145
+ * Check if a user is logged in
146
+ *
147
+ * @return {Bool }
148
+ */
149
+ isLoggedInSync ( ) {
150
+ return currentUser . hasOwnProperty ( 'role' ) ;
151
+ } ,
152
+
135
153
/**
136
154
* Check if a user has a specified role or higher
137
155
* (synchronous|asynchronous)
@@ -158,6 +176,20 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
158
176
} ) ;
159
177
} ,
160
178
179
+ /**
180
+ * Check if a user has a specified role or higher
181
+ *
182
+ * @param {String } role - the role to check against
183
+ * @return {Bool }
184
+ */
185
+ hasRoleSync ( role ) {
186
+ var hasRole = function ( r , h ) {
187
+ return userRoles . indexOf ( r ) >= userRoles . indexOf ( h ) ;
188
+ } ;
189
+
190
+ return hasRole ( currentUser . role , role ) ;
191
+ } ,
192
+
161
193
/**
162
194
* Check if a user is an admin
163
195
* (synchronous|asynchronous)
@@ -170,6 +202,15 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
170
202
. apply ( Auth , [ ] . concat . apply ( [ 'admin' ] , arguments ) ) ;
171
203
} ,
172
204
205
+ /**
206
+ * Check if a user is an admin
207
+ *
208
+ * @return {Bool }
209
+ */
210
+ isAdminSync ( ) {
211
+ return Auth . hasRoleSync ( 'admin' ) ;
212
+ } ,
213
+
173
214
/**
174
215
* Get auth token
175
216
*
0 commit comments