I am using the following hook to prevent some users from signing up via lock.
module.exports = function (user, context, cb) {
// Whitelisted domains
const whitelist =
'example.com',
'example1.com'
];
const userHasAccess = whitelist.some(domain => {
const emailSplit = user.email.split('@');
return emailSplit[emailSplit.length - 1].toLowerCase() === domain;
});
if (!userHasAccess) {
return cb('You may not sign up with an email address using your current domain.');
}
const response = { user };
return cb(null, response);
};
Runner and console show that it’s posting the 500 error. The runner displays the correct response and status code.
However I get:
“WE’RE SORRY, SOMETHING WENT WRONG WHEN ATTEMPTING TO SIGN UP.” instead of:
“You may not sign up with an email address using your current domain.” I am using lock on a hosted login page.
How can I fix this?