Skip to content

Instantly share code, notes, and snippets.

@SippieCup
Last active July 25, 2017 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SippieCup/30b9cfb286e943058633d25faecc202b to your computer and use it in GitHub Desktop.
Save SippieCup/30b9cfb286e943058633d25faecc202b to your computer and use it in GitHub Desktop.
MailGun Verification
module.exports = function (ExtendedUserModel) {
ExtendedUserModel.afterRemote('create', function(context, user, next) {
sendVerificationEmail(user).then( () => next());
function sendVerificationEmail(user) {
var options = {
type: 'mailgunEmail',
to: user.email,
from: 'noreply@mailGun.com',
subject: 'Thanks for registering.',
user: user
};
return user.verify(options);
}
)};
}
// in ExtendedUserModel.json add the property "emailVerificationRequired": true to the root so it looks like this
// DONT DEFINE THIS IN JAVASCRIPT! I just var'd it so I dont need a second gist to have it formatted)
var ExtendedUserModel =
{
"name": "ExtendedUserModel",
"base": "User",
"idInjection": true,
"options": {
"validateUpsert": true,
"caseSensitiveEmail": false
},
"restrictResetPasswordTokenScope": true,
"emailVerificationRequired": true,
"properties": {},
"validations": []
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment