Last active
July 25, 2017 12:06
-
-
Save SippieCup/30b9cfb286e943058633d25faecc202b to your computer and use it in GitHub Desktop.
MailGun Verification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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