fix: solve github return undefined

This commit is contained in:
Kai-Siang Wang 2022-03-11 17:02:02 +08:00
parent 95879d9c17
commit 7443c433f2

View File

@ -1,6 +1,5 @@
'use strict';
const _ = require('lodash');
const jwt = require('jsonwebtoken');
// Purest strategies.
const purest = require('purest');
@ -85,7 +84,7 @@ module.exports = async ({ provider, access_token, query, providers }) => {
};
}
// Get the email with Github's user/emails API
github
return github
.get('user/emails')
.auth(access_token)
.request()
@ -236,8 +235,7 @@ module.exports = async ({ provider, access_token, query, providers }) => {
.auth(access_token)
.request()
.then(({ body }) => {
const username =
body.username || body.nickname || body.name || body.email.split('@')[0];
const username = body.username || body.nickname || body.name || body.email.split('@')[0];
const email = body.email || `${username.replace(/\s+/g, '.')}@strapi.io`;
return {