Has anyone : restricted users to email domain, and used email verification?

8 views
Skip to first unread message

Matt

unread,
Oct 29, 2009, 1:13:30 PM10/29/09
to Lovd by Less
Just wondering if anyone has restricted users to a list of email
domains, and also used an email verification to make sure they are
actually using that email.

Christoph Jasinski

unread,
Oct 29, 2009, 6:12:48 PM10/29/09
to lovdb...@googlegroups.com
Just wondering if anyone has restricted users to a list of email domains, and also used an email verification to make sure they are actually using that email.

If I got you right, you're talking about sign up mail accounts. When a user put it into the form you have to validate it (with regular expressions) to match your allowed pattern or to print an error. (you need some code?)

email verification is included in the restful authentication plugin (http://agilewebdevelopment.com/plugins/restful_authentication). See the code if you don't use this or see some alternative.

Cheers,
Chris

Matt

unread,
Oct 29, 2009, 10:49:46 PM10/29/09
to Lovd by Less
Basically I want a table of domains for email addresses.

For instance, I want to limit everyone on my lovdbyless to gmail.com.
So someone has to sign up with a gmail.com email address, then the
email has to be verified for account use.

On Oct 29, 5:12 pm, Christoph Jasinski

Christoph Jasinski

unread,
Oct 30, 2009, 3:09:35 AM10/30/09
to lovdb...@googlegroups.com
That's easy. Maybe after breakfast. ;)

Christoph Jasinski

unread,
Oct 30, 2009, 8:40:34 AM10/30/09
to lovdb...@googlegroups.com
I think of two approaches for solving this:

1) letting user type their full email address

2) letting user type the prefix of their email address. Ex. bob for b...@gmail.com. User could select from a list of mail hosts like (gmail, hotmail, ...) 

3) add a domain field to the form

-------------------------------------------------------------------------------------

1) extend the regular expression in the user model (~line 33) so that it fits the domains you allow
    validates_format_of :email, :with => /^([^@\s]{1}+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :on => :create, :message=>"Invalid email address or domain."

2) add a select field to your form which get values from (let's say) a constant in your User model where you store the allowed domain like ALLOWED_DOMAIN=[...]. You still can keep the validation for the whole email address (before validation concatenate the two fields).

3) let people type in their username and the domain into the next field (ex. e_domain)
than you can add a validation to that field like
validates_inclussion_of :e_domain, :in => [gmail.com, hotmail.com,....]

That's not the complete code but a point from which you can start.


Chris

Reply all
Reply to author
Forward
0 new messages