Angular:
Firebase:
**AngularFire: 2
**Other (e.g. Ionic/Cordova, Node, browser, operating system): ionic 3
Hello,
Is it possible to use custom claims to add and retrieve user roles with angularfire2 ?
Thanks for your help
Can you elaborate? You certainly can have a user store with users and their roles. Then you can have logic in your db rules to check for certain permissions. If use needs those claims locally they could get them from the store, although it would be good to have logic in the rules so that they can only return their own.
Do you mean you want the Firebase Authentication's JWT to contain custom claims?
Can we set custom claims using Angular not NODE.JS.
@musaddiq-pk please do not comment on closed issues. - One way to store JWT claims with angular is using the built in localstorage.
Yes, we can set the custom claims from backend server like:
firebaseAdmin.auth().setCustomUserClaims(userDocUid, customClaimsData)
And retrieve the claims in client side as :
this.angularFireAuth.idTokenResult.subscribe(idTokenResult => {
const claims = idTokenResult.claims;
});
Most helpful comment
Yes, we can set the custom claims from backend server like:
firebaseAdmin.auth().setCustomUserClaims(userDocUid, customClaimsData)
And retrieve the claims in client side as :
this.angularFireAuth.idTokenResult.subscribe(idTokenResult => {