Skip to content

Commit

Permalink
feat: add emails and phoneNumbers as arrays into the id token as well
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Oct 2, 2024
1 parent 558069a commit 8879f10
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/build/recipe/oauth2provider/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ async function loginGET({
},
userContext,
});
console.log("reject", reject);
return { status: "REDIRECT", redirectTo: reject.redirectTo, cookies };
}
} catch (_c) {
Expand Down
2 changes: 2 additions & 0 deletions lib/build/recipe/oauth2provider/recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class Recipe extends recipeModule_1.default {
payload.email_verified = user.loginMethods.some(
(lm) => lm.hasSameEmailAs(user === null || user === void 0 ? void 0 : user.emails[0]) && lm.verified
);
payload.emails = user.emails;
}
if (scopes.includes("phoneNumber")) {
payload.phoneNumber = user === null || user === void 0 ? void 0 : user.phoneNumbers[0];
Expand All @@ -237,6 +238,7 @@ class Recipe extends recipeModule_1.default {
lm.hasSamePhoneNumberAs(user === null || user === void 0 ? void 0 : user.phoneNumbers[0]) &&
lm.verified
);
payload.phoneNumbers = user.phoneNumbers;
}
for (const fn of this.idTokenBuilders) {
payload = Object.assign(Object.assign({}, payload), await fn(user, scopes, sessionHandle, userContext));
Expand Down
2 changes: 2 additions & 0 deletions lib/ts/recipe/oauth2provider/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,14 @@ export default class Recipe extends RecipeModule {
if (scopes.includes("email")) {
payload.email = user?.emails[0];
payload.email_verified = user.loginMethods.some((lm) => lm.hasSameEmailAs(user?.emails[0]) && lm.verified);
payload.emails = user.emails;
}
if (scopes.includes("phoneNumber")) {
payload.phoneNumber = user?.phoneNumbers[0];
payload.phoneNumber_verified = user.loginMethods.some(
(lm) => lm.hasSamePhoneNumberAs(user?.phoneNumbers[0]) && lm.verified
);
payload.phoneNumbers = user.phoneNumbers;
}

for (const fn of this.idTokenBuilders) {
Expand Down

0 comments on commit 8879f10

Please sign in to comment.