From 0acace58c31c96fc1f8836167aeb4f204f72617f Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 18 Jul 2013 17:17:36 +0200 Subject: allow available and unique forwards only --- users/app/models/local_email.rb | 30 ------------------------------ 1 file changed, 30 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 e71d494..c1f7c11 100644 --- a/users/app/models/local_email.rb +++ b/users/app/models/local_email.rb @@ -1,10 +1,5 @@ class LocalEmail < Email -=begin - validate :unique_on_server - validate :unique_alias_for_user - validate :differs_from_login -=end def self.domain APP_CONFIG[:domain] @@ -16,8 +11,6 @@ class LocalEmail < Email :message => "needs to end in @#{domain}" } - - def initialize(s) super append_domain_if_needed @@ -37,29 +30,6 @@ class LocalEmail < Email protected - def unique_on_server - has_email = User.find_by_login_or_alias(username) - if has_email && has_email != self.casted_by - errors.add :username, "has already been taken" - end - end - - def unique_alias_for_user - aliases = self.casted_by.email_aliases - if aliases.select{|a|a.username == self.username}.count > 1 - errors.add :username, "is already your alias" - end - end - - def differs_from_login - # If this has not changed but the email let's mark the email invalid instead. - return if self.persisted? - user = self.casted_by - if user.login == self.username - errors.add :username, "may not be the same as your email address" - end - end - def append_domain_if_needed unless self.index('@') self << '@' + domain -- cgit v1.2.3