How to Validate User Emails During Account Creation Using Controller Rules and UI Validation

Original Slack Thread

Hello everyone! Questions about creating users. Is there a way to setup rules to validate the emails that users use to create a new account?

I’d like to check the domain of the email, for instance, to prevent using personal emails

Right now I’m inviting users to create account with the invite links

Well, doing a bit more research -> it looks like I should be able to add more rules here:
https://github.com/datahub-project/datahub/blob/master/datahub-frontend/app/controllers/AuthenticationController.java#L209-L219

Alright, I confirm that it’s simple enough to add additional checks in this part of the controller and it does what I need!

You can pair the Controller checks with a validator in the UI to make it easier for the user to know why the signup is failing:
https://github.com/datahub-project/datahub/blob/master/datahub-web-react/src/app/auth/SignUp.tsx#L151-L157

Thanks so much for sharing the update, Pierre! :slight_smile:

No worry! We ended up updating both the controller and the view and it works like a charm! :smile: