Sha256: 2b04afe7c1f2eb481d042747b06a287a769e62978feff5e4314853661e9fd20a

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

module Nyauth
  class PasswordsController < Nyauth::BaseController
    before_action -> { require_authentication! as: nyauth_client_name }
    before_action :set_client

    def edit
    end

    def update
      @client.attributes = client_params
      @client.password_digest_will_change! # HACK for Rails5beta2 https://github.com/rails/rails/issues/23645
      @client.save(context: :update_password)
      respond_with(@client, location: Nyauth.configuration.redirect_path_after_update_password.call(nyauth_client_name) || main_app.root_path)
    end

    private

    def set_client
      @client = nyauth_client_class.find(current_authenticated(as: nyauth_client_name).id)
    end

    def client_params
      params.fetch(nyauth_client_name, {})
            .permit(:password, :password_confirmation)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyauth-0.7.0 app/controllers/nyauth/passwords_controller.rb