Sha256: 92fa1d0af90ec863721810ac97061fff828fbd38ba156cd0e070763e2d882448

Contents?: true

Size: 822 Bytes

Versions: 14

Compression:

Stored size: 822 Bytes

Contents

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

  def edit
  end

  def update
    if !@<%= singular_table_name %>.authenticate(params[:current_password])
      redirect_to edit_passwords_path, alert: "The current password you entered is incorrect"
    elsif @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>)
      redirect_to root_path, notice: "Your password has been changed successfully"
    else
      render :edit, 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.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
    end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
authentication-zero-2.0.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-1.0.2 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-1.0.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-1.0.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.24 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.23 lib/generators/authentication/templates/app/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.22 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.21 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.20 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.19 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.18 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.17 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.16 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.15 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt