Skip to content

Commit

Permalink
fix: fixed email for ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Apr 23, 2024
1 parent 8d0b2e5 commit bb92ff5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ class Passport extends KoaPassport {
}

getEmailFromProfile(provider, profile) {
if (
provider === 'ubuntu' &&
_.isArray(profile.email) &&
!_.isEmpty(profile.email) &&
validator.isEmail(profile.email[0])
)
return profile.email[0];
if (
provider === 'apple' &&
_.isString(profile.email) &&
Expand All @@ -301,9 +308,6 @@ class Passport extends KoaPassport {
refreshToken = null;
if (!_.isArray(profile.nickname) || !isSANB(profile.nickname[0]))
return done(new Error(this.config.phrases.INVALID_PROFILE_ID));
// helper alias to re-use existing function which has plural form
if (_.isArray(profile.email) && !_.isEmpty(profile.email))
profile.emails = profile.email;
}

if (!_.isObject(profile))
Expand Down

0 comments on commit bb92ff5

Please sign in to comment.