diff options
author | elijah <elijah@riseup.net> | 2014-12-15 16:07:30 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-12-15 16:07:30 -0800 |
commit | 6e15813d549fd9e56a48fd87d425fd31f37521e8 (patch) | |
tree | 730134da23e7904059c26973f856762f99f0d56d | |
parent | b59360a003af595f1552f2ce753d4d80e5cf0028 (diff) |
bugfix: allow deletion of user's identities via api when user is deleted. closes #6550
-rw-r--r-- | app/controllers/v1/users_controller.rb | 2 | ||||
-rw-r--r-- | app/models/account.rb | 8 | ||||
-rw-r--r-- | engines/support/app/models/account_extension/tickets.rb | 4 |
3 files changed, 9 insertions, 5 deletions
diff --git a/app/controllers/v1/users_controller.rb b/app/controllers/v1/users_controller.rb index d57db6f..2e840d9 100644 --- a/app/controllers/v1/users_controller.rb +++ b/app/controllers/v1/users_controller.rb @@ -30,7 +30,7 @@ module V1 end def destroy - @user.account.destroy + @user.account.destroy(params[:identities] == "destroy") if @user == current_user logout end diff --git a/app/models/account.rb b/app/models/account.rb index 67fec58..d13c929 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -47,9 +47,13 @@ class Account @user.refresh_identity end - def destroy + def destroy(destroy_identity=false) return unless @user - Identity.disable_all_for(@user) + if destroy_identity == false + Identity.disable_all_for(@user) + else + Identity.destroy_all_for(@user) + end @user.destroy end diff --git a/engines/support/app/models/account_extension/tickets.rb b/engines/support/app/models/account_extension/tickets.rb index f898b56..f38d5fd 100644 --- a/engines/support/app/models/account_extension/tickets.rb +++ b/engines/support/app/models/account_extension/tickets.rb @@ -1,9 +1,9 @@ module AccountExtension::Tickets extend ActiveSupport::Concern - def destroy_with_tickets + def destroy_with_tickets(destroy_identities=false) Ticket.destroy_all_from(self.user) - destroy_without_tickets + destroy_without_tickets(destroy_identities) end included do |