Sha256: 4da171d11fb258f5ff65d03bf035ace8ac55b9731d185d4ea7e0794e7f6b1e06

Contents?: true

Size: 771 Bytes

Versions: 10

Compression:

Stored size: 771 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_password_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"
    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.permit(:password, :password_confirmation)
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authentication-zero-2.11.2 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.11.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.11.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.10.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.9.3 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.9.2 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.9.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.9.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.8.4 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.8.3 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt