File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import {Observable} from "rxjs";
3
3
import { AngularFireAuth } from "@angular/fire/auth" ;
4
4
import { map } from "rxjs/operators" ;
5
5
import { Router } from "@angular/router" ;
6
+ import { UserRoles } from "../model/user-roles" ;
6
7
7
8
8
9
@Injectable ( {
@@ -16,6 +17,8 @@ export class UserService {
16
17
17
18
pictureUrl$ : Observable < string > ;
18
19
20
+ roles$ : Observable < UserRoles > ;
21
+
19
22
constructor (
20
23
private afAuth : AngularFireAuth ,
21
24
private router : Router ) {
@@ -27,6 +30,11 @@ export class UserService {
27
30
this . pictureUrl$ =
28
31
afAuth . authState . pipe ( map ( user => user ? user . photoURL : null ) ) ;
29
32
33
+ this . roles$ = this . afAuth . idTokenResult
34
+ . pipe (
35
+ map ( token => < any > token ?. claims ?? { admin :false } )
36
+ )
37
+
30
38
}
31
39
32
40
You can’t perform that action at this time.
0 commit comments