Sha256: a33859b6ce12aec237efb2c8b6aa27c21341582c12024b72bc0b22f7b722bd46

Contents?: true

Size: 772 Bytes

Versions: 49

Compression:

Stored size: 772 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(<%= "#{singular_table_name}_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 <%= "#{singular_table_name}_params" %>
      params.permit(:password, :password_confirmation)
    end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
authentication-zero-2.11.2 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.11.1 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.11.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.10.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.9.3 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.9.2 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.9.1 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.9.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.8.4 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.8.3 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.8.2 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.8.1 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.8.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.7.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.6.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.5.1 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.5.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.4.0 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.3.6 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
authentication-zero-2.3.5 lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt