File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export const TOKEN_IDENT = 'token';
11
11
export class AuthService {
12
12
13
13
constructor ( private apiService : ApiService , public helperService : JwtHelperService ) { }
14
+
14
15
// TODO: store refresh token
15
16
login ( username : string , password : string ) {
16
17
return this . apiService . login ( username , password ) .
@@ -19,6 +20,20 @@ export class AuthService {
19
20
) ) ;
20
21
}
21
22
23
+ userIsAdmin ( ) : boolean {
24
+ const rawToken = this . getToken ( ) ;
25
+ if ( rawToken && this . isValid ( ) ) {
26
+ try {
27
+ const token = this . helperService . decodeToken ( rawToken ) ;
28
+ return token . user_type === 'Admin' ;
29
+ } catch {
30
+ return false ;
31
+ }
32
+ } else {
33
+ return false ;
34
+ }
35
+ }
36
+
22
37
isValid ( ) : boolean {
23
38
// TODO: for dev purpose it will be sufficient to return true here and thereby skipp
24
39
// the authorization in the complete application
You can’t perform that action at this time.
0 commit comments