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';
1111export class AuthService {
1212
1313 constructor ( private apiService : ApiService , public helperService : JwtHelperService ) { }
14+
1415 // TODO: store refresh token
1516 login ( username : string , password : string ) {
1617 return this . apiService . login ( username , password ) .
@@ -19,6 +20,20 @@ export class AuthService {
1920 ) ) ;
2021 }
2122
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+
2237 isValid ( ) : boolean {
2338 // TODO: for dev purpose it will be sufficient to return true here and thereby skipp
2439 // the authorization in the complete application
You can’t perform that action at this time.
0 commit comments