Skip to content

Commit dadbde4

Browse files
author
David Lenton
committed
Merged in fix-apple-signin-issues (pull request auth0#21)
Allow apple account gap filling if earlier error
2 parents d12fa07 + 37aac7a commit dadbde4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

routes/api/account.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,16 @@ module.exports = function (app) {
376376
const appId = req.site.server.client_id;
377377
const account = new User(appId);
378378
const username = 'apple_' + userId;
379+
const name = [];
380+
if (givenName) name.push(givenName);
381+
if (familyName) name.push(familyName);
379382
account.loadByUuid(username, (err, user) => {
380383
if (err) return next(err);
381384
account.apple = userId;
382-
// Save the email address here if we missed it before
385+
// Save the email address and other details here if we missed it before
383386
if (!account.email) account.email = email;
387+
if (!account.name) account.name = name.join(' ');
388+
if (!account.username) account.username = email;
384389
if (user !== null) {
385390
account.save(true, (err) => {
386391
if (err) {
@@ -389,9 +394,6 @@ module.exports = function (app) {
389394
return handleTokens(user, deviceId, req, res, next);
390395
});
391396
} else {
392-
const name = [];
393-
if (givenName) name.push(givenName);
394-
if (familyName) name.push(familyName);
395397
account.username = email;
396398
account.email = email;
397399
account.name = name.join(' ');

0 commit comments

Comments
 (0)