summaryrefslogtreecommitdiff
path: root/users/app/models/user.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-18 17:17:36 +0200
committerAzul <azul@leap.se>2013-07-24 10:55:51 +0200
commit0acace58c31c96fc1f8836167aeb4f204f72617f (patch)
tree4738cf2fab5f67afdcdae7373914b9bd66cfd95e /users/app/models/user.rb
parentd96fac2de074bbe3a44d888af5ceaff45b1b9b27 (diff)
allow available and unique forwards only
Diffstat (limited to 'users/app/models/user.rb')
-rw-r--r--users/app/models/user.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index dda5a41..5707f24 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -74,7 +74,7 @@ class User < CouchRest::Model::Base
end
def create_identity(attribs = {}, &block)
- build_identity(attribs, &block)
+ identity = build_identity(attribs, &block)
identity.save
identity
end
@@ -135,12 +135,10 @@ class User < CouchRest::Model::Base
##
def login_is_unique_alias
- has_alias = User.find_by_login_or_alias(username)
+ alias_identity = Identity.find_by_address(self.email_address)
return if has_alias.nil?
- if has_alias != self
+ if alias_identity.user != self
errors.add(:login, "has already been taken")
- elsif has_alias.login != self.login
- errors.add(:login, "may not be the same as one of your aliases")
end
end