From d96fac2de074bbe3a44d888af5ceaff45b1b9b27 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 18 Jul 2013 12:52:02 +0200 Subject: validations of email format and local domain moved over --- users/app/models/local_email.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'users/app/models/local_email.rb') diff --git a/users/app/models/local_email.rb b/users/app/models/local_email.rb index d919102..e71d494 100644 --- a/users/app/models/local_email.rb +++ b/users/app/models/local_email.rb @@ -6,6 +6,18 @@ class LocalEmail < Email validate :differs_from_login =end + def self.domain + APP_CONFIG[:domain] + end + + validates :email, + :format => { + :with => /@#{domain}\Z/i, + :message => "needs to end in @#{domain}" + } + + + def initialize(s) super append_domain_if_needed @@ -16,7 +28,11 @@ class LocalEmail < Email end def handle - gsub(/@#{APP_CONFIG[:domain]}/i, '') + gsub(/@#{domain}/i, '') + end + + def domain + LocalEmail.domain end protected @@ -46,7 +62,7 @@ class LocalEmail < Email def append_domain_if_needed unless self.index('@') - self << "@#{APP_CONFIG[:domain]}" + self << '@' + domain end end -- cgit v1.2.3