From 8e8f5ddda08a883842a8c3e2ffa994e12b25dd39 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 5 Sep 2013 13:56:02 -0700 Subject: Ensure that address in identity really is a LocalEmail. --- users/app/models/identity.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'users/app/models/identity.rb') diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb index 355f67a..e197c9c 100644 --- a/users/app/models/identity.rb +++ b/users/app/models/identity.rb @@ -10,6 +10,7 @@ class Identity < CouchRest::Model::Base validate :unique_forward validate :alias_available + validate :address_local_email design do view :by_user_id @@ -79,4 +80,9 @@ 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 + end -- cgit v1.2.3 From 3ef22b5a856e1f576fb0a6a589b6b7ab41e1dd18 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 5 Sep 2013 14:00:50 -0700 Subject: For moment, have identity's address handle aliased from login so we can use LoginFormatValidation. However, this is not how we will want it eventually. One issue is that the errors messages are set on login, rather than the appropriate field. --- users/app/models/identity.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'users/app/models/identity.rb') diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb index e197c9c..91345a0 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 @@ -64,6 +65,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 -- cgit v1.2.3 From a9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 23 Sep 2013 12:23:08 -0700 Subject: This ensures that email addresses contain only lowercase letters, and that an identity's destination is a valid Email. --- users/app/models/identity.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'users/app/models/identity.rb') diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb index 91345a0..e0a24e9 100644 --- a/users/app/models/identity.rb +++ b/users/app/models/identity.rb @@ -12,6 +12,7 @@ class Identity < CouchRest::Model::Base validate :unique_forward validate :alias_available validate :address_local_email + validate :destination_email design do view :by_user_id @@ -91,4 +92,9 @@ class Identity < CouchRest::Model::Base 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 -- cgit v1.2.3