Prevent user to be added on Dashboard if rules throw error


I have trouble understanding the user creation process.
I have a whitelist rule that call an API to get a list of authorized email address. In the rule, if the user email is not present in the whitelist I call the callback with an error:
return callback(new UnauthorizedError(‘Access denied.’));

However even though the login is canceled with the error, the user is still showing up in the Dashboard users list.
How can I prevent the user to be added to my users if the login is denied?


1 Like

Hi @jimzer,

Welcome to the Community!

You should be able to accomplish this with a pre-registration hook.

Check out this thread:

Thank you.
Would it work with social login ?
Because we use only Google sign in for now. If the pre-registration hook can work for first social logins it would be perfect

1 Like

Ah no I missed that detail, this will not work with social. Social users don’t register, per se. They are only logging in, since they already have registrations with google. You can block them via a rule, or you could probably even delete the user in a rule and return unauthorized…I haven’t seen this done but that doesn’t mean it isn’t possible. I might have time to test it this week.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.