From b79d8ae03339e2957c50111f0eae405ca1440674 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 5 Sep 2013 13:10:23 -0700 Subject: Move handle method to Email model and have it work for local and non-local emails. --- users/app/models/email.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'users/app/models/email.rb') diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 1bcff1c..89c31bb 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -19,4 +19,8 @@ class Email < String self end + def handle + self.split('@').first + end + end -- cgit v1.2.3 From a9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 23 Sep 2013 12:23:08 -0700 Subject: This ensures that email addresses contain only lowercase letters, and that an identity's destination is a valid Email. --- users/app/models/email.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'users/app/models/email.rb') diff --git a/users/app/models/email.rb b/users/app/models/email.rb index 89c31bb..f38f2f5 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -3,10 +3,16 @@ class Email < String validates :email, :format => { - :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, + :with => /\A([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})\Z/, #checks format, but allows lowercase :message => "needs to be a valid email address" } + validates :email, + :format => { + :with => /\A[^A-Z]*\Z/, #forbids uppercase characters + :message => "letters must be lowercase" + } + def to_partial_path "emails/email" end -- cgit v1.2.3 From af9d843d646cf500306de0ad20896c05ecaccd78 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 26 Sep 2013 12:06:25 -0700 Subject: Since local part of email is case sensitive, want to allow remote email addresses with uppercase letters in local part. --- users/app/models/email.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'users/app/models/email.rb') diff --git a/users/app/models/email.rb b/users/app/models/email.rb index f38f2f5..a9a503f 100644 --- a/users/app/models/email.rb +++ b/users/app/models/email.rb @@ -3,16 +3,10 @@ class Email < String validates :email, :format => { - :with => /\A([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})\Z/, #checks format, but allows lowercase + :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, #local part of email is case-sensitive, so allow uppercase letter. :message => "needs to be a valid email address" } - validates :email, - :format => { - :with => /\A[^A-Z]*\Z/, #forbids uppercase characters - :message => "letters must be lowercase" - } - def to_partial_path "emails/email" end -- cgit v1.2.3