How can I use Devise Authentication to validate that a sign up email address is from certain domain?

I would like to make sure the only people with email address of a certain domain can signup for a site that is using Devise.

For instance if people sign-up with the email, they should get a confirmation email but if the sign up with, they should get a error message.


Uncommenting this line in config/initializers/devise.rb

# Regex to use to validate the email address
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i

and changing it to use the domain I wanted to limit to:

config.email_regexp = /\A([\w\.%\+\-]+)@mysite\.com\z/i

did the trick.

Need Your Help

deploy automatically file to tomcat from eclipse

java eclipse tomcat

I have a VPS which I can access via My tomcat location is C:\tomcat\

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.