Class: Decidim::DestroyAccount

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/destroy_account.rb

Overview

This command destroys the user’s account.

Instance Method Summary collapse

Constructor Details

#initialize(user, form) ⇒ DestroyAccount

Destroy a user’s account.

user - The user to be updated. form - The form with the data.



10
11
12
13
# File 'app/commands/decidim/destroy_account.rb', line 10

def initialize(user, form)
  @user = user
  @form = form
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/commands/decidim/destroy_account.rb', line 15

def call
  return broadcast(:invalid) unless @form.valid?

  Decidim::User.transaction do
    destroy_user_account!
    destroy_user_identities
    destroy_user_group_memberships
    destroy_follows
    destroy_participatory_space_private_user
    delegate_destroy_to_participatory_spaces
  end

  broadcast(:ok)
end