af83/chouette-core

View on GitHub
app/controllers/users/registrations_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class Users::RegistrationsController < Devise::RegistrationsController
  before_action :configure_account_update_params, only: [:update]

  protected

  def configure_account_update_params
    devise_parameter_sanitizer.permit(:account_update, keys: [:name,
      :password,
      :password_confirmation,
      :current_password,
      :user_locale,
      :time_zone])
  end

  def update_resource(resource, params)
    if params[:password].present?
      resource.update_with_password(params)
    else
      params.delete :password
      params.delete :password_confirmation
      params.delete :current_password
      resource.update(params)
    end
  end

  private

  def current_organisation
    current_user.organisation
  end
  helper_method :current_organisation
end