Sha256: 0100ac264fd06f46b1f181a4eb34fa6fe91a17460a085cbd85d1a967285f5d6c

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

class PasswordsController < ApplicationController
  before_action :set_<%= singular_table_name %>

  def update
    if !@<%= singular_table_name %>.authenticate(params[:current_password])
      render json: { error: "The current password you entered is incorrect" }, status: :bad_request
    elsif @<%= singular_table_name %>.update(password_params)
      render json: @<%= singular_table_name %>
    else
      render json: @<%= singular_table_name %>.errors, status: :unprocessable_entity
    end
  end

  private
    def set_<%= singular_table_name %>
      @<%= singular_table_name %> = Current.<%= singular_table_name %>
    end

    def password_params
      params.permit(:password, :password_confirmation)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authentication-zero-0.0.12 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt