Skip to content

Modify accepted email domains for devise

agustinus-ap edited this page Apr 18, 2012 · 1 revision

After customize email_regex of devise, know gitlabhq have email domain validation. So how we could add and/or remove the email domains? Follow these steps to modify which are accepted email domains:

  1. Open config/initializers/devise.rb and find domains variable.

     domains = %w(kiranatama.com)
     config.email_regex = Regexp.new "\\A[^@]+@(#{domains.join('|')})\\z", true
    
  2. Next modify domains value as you wish, for example if you wish to add wgs.co.id then write

     domains = %w(kiranatama.com wgs.co.id)
    
  3. Whenever you change a configuration file, make sure you've restart the application before try it again.

And voila, next time you register an user with wgs.co.id email domain it won't reject you anymore.

Clone this wiki locally