Hello,
I have this code in my pre registration hook:
if (
/dev/.test(context.webtask.headers.host) &&
!/example\.com$/.test(user.email)
) {
cb(
new PreUserRegistrationError(
'Denied user registration in Pre User Registration Hook',
'You are not allowed to access this environment.',
),
{ user: null },
);
} else {
const response = {};
response.user = user;
cb(null, response);
}
It’s designed to prevent users with email addresses that don’t end on example.com from signing up on to tenants with dev in the name.
When I try to sign up with user foo@bar.com on my dev tenant I do get the “You are not allowed to access this environment.” message and my app handles kicking the user back to the public space but at the back user is still being created in the database.
I would expect that throwing the PreUserRegistrationError like I do here would stop user from ever getting to the database. Can you please advise?
Thanks,
Maciej