summaryrefslogtreecommitdiff
path: root/users/app/models/identity.rb
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-10-10 10:56:09 -0700
committerjessib <jessib@riseup.net>2013-10-10 10:56:09 -0700
commit0acbf6a158f149c1f4273bde0cfca47547e080f8 (patch)
tree7e836d84ef8b879670b54eaaf6a8d3ae53ab7e14 /users/app/models/identity.rb
parentb60a75d8cbe25ac47bb037e9e54a7cf4e2ba4e1f (diff)
parentd6491496704b3909a93b5883f049becb408e0e47 (diff)
Merge pull request #96 from azul/release/0.2.4
Release/0.2.4
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