summaryrefslogtreecommitdiff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-02-10 10:56:57 -0800
committerelijah <elijah@riseup.net>2016-02-10 10:56:57 -0800
commit49d3e9df74685fe17a2abbbabdd17014f2371065 (patch)
tree41dc44c41659e2f970b84ac2fe0da8152422efee /app/models/account.rb
parent0ba489bdb01bb2f0536d2603bd389d448712e336 (diff)
allow user accounts to be re-enabled, and for associated identities to also get re-enabled.
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb22
1 files changed, 18 insertions, 4 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 46e5446..abde89d 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -59,11 +59,15 @@ class Account
def destroy(destroy_identity=false)
return unless @user
- if !user.tmp?
+ if !@user.tmp?
if destroy_identity == false
- Identity.disable_all_for(@user)
+ @user.identities.each do |id|
+ id.orphan!
+ end
else
- Identity.destroy_all_for(@user)
+ @user.identities.each do |id|
+ id.destroy
+ end
end
end
@user.destroy
@@ -76,7 +80,17 @@ class Account
if @user && !@user.tmp?
@user.enabled = false
@user.save
- Identity.remove_cert_fingerprints_for(@user)
+ @user.identities.each do |id|
+ id.disable!
+ end
+ end
+ end
+
+ def enable
+ @user.enabled = true
+ @user.save
+ @user.identities.each do |id|
+ id.enable!
end
end