summaryrefslogtreecommitdiff
path: root/users/app/models/identity.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-11-05 11:40:25 +0100
committerAzul <azul@leap.se>2013-11-05 11:40:25 +0100
commitb4ca13257341792f5e6496264c421af1888bcdb8 (patch)
treece573e9b360b389ab83f21fc360e9d9434423f63 /users/app/models/identity.rb
parentd4f835662fac2d9dca705b5cba2e207562dec833 (diff)
refactor: Identity.disable_all_for(user) on user destruction
This way the identity model defines how identities should be disabled. We currently still destroy them. But it will be easy and nicely isolated to change this next.
Diffstat (limited to 'users/app/models/identity.rb')
-rw-r--r--users/app/models/identity.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb
index e0a24e9..c24af73 100644
--- a/users/app/models/identity.rb
+++ b/users/app/models/identity.rb
@@ -50,6 +50,12 @@ class Identity < CouchRest::Model::Base
identity
end
+ def self.disable_all_for(user)
+ Identity.by_user_id.key(user.id).each do |identity|
+ identity.disable
+ end
+ end
+
def self.attributes_from_user(user)
{ user_id: user.id,
address: user.email_address,
@@ -57,6 +63,12 @@ class Identity < CouchRest::Model::Base
}
end
+ #
+ # about to change towards actually disabling the identity instead of
+ # destroying it.
+ #
+ alias_method :disable, :destroy
+
def keys
read_attribute('keys') || HashWithIndifferentAccess.new
end