Class: Decidim::Devise::PasswordsController

Inherits:
Devise::PasswordsController
  • Object
show all
Includes:
Decidim::DeviseControllers
Defined in:
app/controllers/decidim/devise/passwords_controller.rb

Overview

Custom Devise PasswordsController to avoid namespace problems.

Instance Method Summary collapse

Instance Method Details

#apply_passwordObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/decidim/devise/passwords_controller.rb', line 24

def apply_password
  self.resource = current_user
  @send_path = apply_password_path

  @form = Decidim::PasswordForm.from_params(params["user"])
  Decidim::UpdatePassword.call(current_user, @form) do
    on(:ok) do
      flash[:notice] = t("passwords.update.success", scope: "decidim")
      (current_user)
      redirect_to  current_user
    end

    on(:invalid) do
      flash.now[:alert] = t("passwords.update.error", scope: "decidim")
      resource.errors.errors.concat(@form.errors.errors)
      render action: "edit"
    end
  end
end

#change_passwordObject



16
17
18
19
20
21
22
# File 'app/controllers/decidim/devise/passwords_controller.rb', line 16

def change_password
  self.resource = current_user
  @send_path = apply_password_path

  flash[:secondary] = t("decidim.admin.password_change.notification", days: Decidim.config.admin_password_expiration_days) if flash[:secondary].blank?
  render :edit
end