开发者

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

开发者 https://www.devze.com 2023-01-27 22:35 出处:网络
开发者_运维百科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.
开发者_运维百科

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 joe@mysite.com, they should get a confirmation email but if the sign up with joe@yoursite.com, 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消