Created
November 20, 2018 17:22
-
-
Save Tanver-Hasan/e18491bd229c19a604da604d4dd6eb16 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function (user, context, callback) { | |
const ManagementClient = require('[email protected]').ManagementClient; | |
var emailVerified = user && user.email_verified ? user.email_verified : false; | |
if (!emailVerified) { | |
var management = new ManagementClient({ | |
token: auth0.accessToken, | |
domain: auth0.domain | |
}); | |
var data = { | |
user_id: user.user_id | |
}; | |
management.sendEmailVerification(data, function (err, message) { | |
if (err) { | |
console.log(err); | |
} | |
console.log(message); | |
}); | |
console.log("executed"); | |
return callback(new UnauthorizedError('Please Verify your email address.')); | |
} else { | |
return callback(null, user, context); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment