Sha256: 556b89b29ed857cdc0a0137735d63aed9c2087d8efc87f839909131c136dea50

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

class PasswordsController < ApplicationController
  def edit
    @<%= singular_table_name %> = Current.<%= singular_table_name %>
  end

  def update
    if !Current.<%= singular_table_name %>.authenticate(params[:current_password])
      redirect_to password_edit_path, alert: "The current password you entered is incorrect"
    elsif Current.<%= singular_table_name %>.update(password_params)
      redirect_to root_path, notice: "Your password has been changed successfully"
    else
      render :edit, status: :unprocessable_entity
    end
  end

  private
    def password_params
      params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation)
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
authentication-zero-0.0.4 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.3 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.2 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
authentication-zero-0.0.1 lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt