summaryrefslogtreecommitdiff
path: root/users/app/models/identity.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-10-10 09:52:16 +0200
committerAzul <azul@leap.se>2013-10-10 09:52:16 +0200
commitb676e6e6f5367d1be540af817062a77ee3fe7f00 (patch)
tree107c50e838d3fe2feb7da932869a9aabc62ce46b /users/app/models/identity.rb
parentb60a75d8cbe25ac47bb037e9e54a7cf4e2ba4e1f (diff)
parenteaedf19e2e54ccb9933caa8dc21df13e48609b18 (diff)
Merge remote-tracking branch 'leap/develop'
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