Skip to content

Commit

Permalink
Merge pull request #11 from dead8309/main
Browse files Browse the repository at this point in the history
feat: Support Edge cases where Email is missing
  • Loading branch information
dead8309 authored Mar 27, 2024
2 parents 80903c6 + 526d559 commit a541dc8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class FirebaseJWTStrategy extends JWTStrategy {
try {
const token = authentication.accessToken ?? authentication.access_token;
const user = await firebaseAdmin.auth().verifyIdToken(token);
console.log('user', user);
if (!user) {
throw new NotAuthenticated();
}
Expand Down Expand Up @@ -91,6 +92,12 @@ export class FirebaseJWTStrategy extends JWTStrategy {
_existingEntity?: any,
_params?: Params,
) {
let email = user.email;
// For Edge cases where email is not provided in the token
if (!email) {
const record = await firebaseAdmin.auth().getUser(user.uid);
email = record.providerData[0].email;
}
return {
uid: user.uid,
email: user.email,
Expand Down

0 comments on commit a541dc8

Please sign in to comment.