I need to access custom claims on the client, but cannot.
The docs indicate to use firebase.auth().currentUser.getIdTokenResult()
For over a year I have had zero luck getting anything from
firebase.auth().currentUser.getIdTokenResult()The only way I am able to access user info from the client is firebase.auth().onAuthStateChanged(function(user)
This code does not work. Always returns undefined.
firebase.auth().currentUser.getIdTokenResult()
.then((idTokenResult) => {
// Confirm the user is an Admin.
if (!!idTokenResult.claims.admin) {
// Show admin UI.
showAdminUI();
} else {
// Show regular user UI.
showRegularUI();
}
})
.catch((error) => {
console.log(error);
});