Skip to content

Commit 84e047e

Browse files
author
dmlenton
committed
Make sure we get an Apple email address
1 parent 55caeef commit 84e047e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

routes/api/account.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ module.exports = function (app) {
359359
// Additional verification not used
360360
// const authorizationCode = req.body.authorizationCode;
361361
// const nonce = req.body.nonce;
362-
const email = req.body.email;
362+
// let email = req.body.email;
363363
const givenName = req.body.givenName;
364364
const familyName = req.body.familyName;
365-
const { sub: userAppleId } = await appleSignin.verifyIdToken(token, {
365+
const { sub: userAppleId, email } = await appleSignin.verifyIdToken(token, {
366366
// Optional Options for further verification - Full list can be found here https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback
367367
// audience: 'localhost', // client id - can also be an array
368368
// nonce: 'NONCE', // nonce
@@ -378,6 +378,8 @@ module.exports = function (app) {
378378
account.loadByUuid(username, (err, user) => {
379379
if (err) return next(err);
380380
account.apple = userId;
381+
// Save the email address here if we missed it before
382+
if (!account.email) account.email = email;
381383
if (user !== null) {
382384
account.save(true, (err) => {
383385
if (err) {

0 commit comments

Comments
 (0)