Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created December 9, 2017 22:27
Show Gist options
  • Save hiranya911/2fef4d522f4863366c967e8c1ce1bf28 to your computer and use it in GitHub Desktop.
Save hiranya911/2fef4d522f4863366c967e8c1ce1bf28 to your computer and use it in GitHub Desktop.
firebase.auth().currentUser.getIdToken()
.then((idToken) => {
// Parse the ID token.
const payload = JSON.parse(b64DecodeUnicode(idToken.split('.')[1]));
var role = payload['role'];
if (role == 'moderator') {
showModeratorUI();
} else {
showArticleFeed();
}
})
.catch((error) => {
console.log(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment