Sha256: 45a0717ad151938bcf4de2193393d14297674e24592ff557fa50a9af0edbd2b2

Contents?: true

Size: 808 Bytes

Versions: 24

Compression:

Stored size: 808 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.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
    end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
authentication-zero-2.8.2 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.8.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.8.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.7.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.6.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.5.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.5.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.4.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.6 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.5 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.4 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.3 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.2 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.3.0 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.2.10 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.2.7 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.2.6 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.2.5 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-2.2.4 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt