diff options
author | Azul <azul@leap.se> | 2013-07-18 12:28:51 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-07-24 10:55:50 +0200 |
commit | a2e49d1b946fa34dd41ce1f07920515df13e09db (patch) | |
tree | ddd2dcd48954c50b676b2f585e1c29a7f477faf0 /users/app/models | |
parent | cc96c60c4617c09379d5e1ddbefa42407329c19a (diff) |
local email adds domain if needed
Diffstat (limited to 'users/app/models')
-rw-r--r-- | users/app/models/local_email.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/users/app/models/local_email.rb b/users/app/models/local_email.rb index 1cadc71..d919102 100644 --- a/users/app/models/local_email.rb +++ b/users/app/models/local_email.rb @@ -6,15 +6,17 @@ class LocalEmail < Email validate :differs_from_login =end - - def email=(value) - return if value.blank? - self.username = value - strip_domain_if_needed + def initialize(s) + super + append_domain_if_needed end def to_key - [username] + [handle] + end + + def handle + gsub(/@#{APP_CONFIG[:domain]}/i, '') end protected @@ -42,8 +44,10 @@ class LocalEmail < Email end end - def strip_domain_if_needed - self.username.gsub! /@#{APP_CONFIG[:domain]}/i, '' + def append_domain_if_needed + unless self.index('@') + self << "@#{APP_CONFIG[:domain]}" + end end end |