- Add support for welcome email on user creation (both OAuth and password users) - Add support for html/text templating on verify email. - Add support for html/text templating on reset password. - Add handlers for converting Handlebars templates to HTML and text (template agnostic). - Add helper function sendEmail() for compiling and sending templates via Email.send() (SMTP).
42 lines
999 B
JavaScript
42 lines
999 B
JavaScript
const parseGoogleData = service => {
|
|
return {
|
|
email: service.email,
|
|
name: {
|
|
first: service.given_name,
|
|
last: service.family_name,
|
|
},
|
|
};
|
|
};
|
|
|
|
const parseGithubData = (profile, service) => {
|
|
const name = profile.name.split(' ');
|
|
return {
|
|
email: service.email,
|
|
name: {
|
|
first: name[0],
|
|
last: name[1],
|
|
},
|
|
};
|
|
};
|
|
|
|
const parseFacebookData = service => {
|
|
return {
|
|
email: service.email,
|
|
name: {
|
|
first: service.first_name,
|
|
last: service.last_name,
|
|
},
|
|
};
|
|
};
|
|
|
|
const getDataForService = (profile, services) => {
|
|
if (services.facebook) return parseFacebookData(services.facebook);
|
|
if (services.github) return parseGithubData(profile, services.github);
|
|
if (services.google) return parseGoogleData(services.google);
|
|
};
|
|
|
|
export default (options, user) => {
|
|
const isOAuth = !options.password;
|
|
const serviceData = isOAuth ? getDataForService(options.profile, user.services) : null;
|
|
return isOAuth ? serviceData : null;
|
|
};
|