summaryrefslogtreecommitdiff
path: root/users/app/models/identity.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-09-24 01:37:57 -0700
committerazul <azul@riseup.net>2013-09-24 01:37:57 -0700
commit98db0cc42019dfcd90d58e0126fe691590fde2e2 (patch)
treec8a3bf7fe4c8001718ea31e56d036b267ee362e6 /users/app/models/identity.rb
parentc081062ea16526dfbf3ad9ba0fdec724be67949c (diff)
parenta9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 (diff)
Merge pull request #88 from jessib/feature/only_lower_case_aliases
Feature/only lower case aliases
Diffstat (limited to 'users/app/models/identity.rb')
-rw-r--r--users/app/models/identity.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb
index 355f67a..e0a24e9 100644
--- a/users/app/models/identity.rb
+++ b/users/app/models/identity.rb
@@ -1,4 +1,5 @@
class Identity < CouchRest::Model::Base
+ include LoginFormatValidation
use_database :identities
@@ -10,6 +11,8 @@ class Identity < CouchRest::Model::Base
validate :unique_forward
validate :alias_available
+ validate :address_local_email
+ validate :destination_email
design do
view :by_user_id
@@ -63,6 +66,11 @@ class Identity < CouchRest::Model::Base
write_attribute('keys', keys.merge(type => value))
end
+ # for LoginFormatValidation
+ def login
+ self.address.handle
+ end
+
protected
def unique_forward
@@ -79,4 +87,14 @@ class Identity < CouchRest::Model::Base
end
end
+ def address_local_email
+ return if address.valid? #this ensures it is LocalEmail
+ self.errors.add(:address, address.errors.messages[:email].first) #assumes only one error
+ end
+
+ def destination_email
+ return if destination.valid? #this ensures it is Email
+ self.errors.add(:destination, destination.errors.messages[:email].first) #assumes only one error #TODO
+ end
+
end