class Admin::HomeController < ApplicationController
  before_action :authenticate_admin!
  layout 'admin'
  def index
    @admin = current_admin
  end

  def change_pass
    @admin = current_admin
    if params[:admin][:password].blank?
      params[:admin].delete(:password)
      params[:admin].delete(:password_confirmation)
    end
    if @admin.update(admin_params)
      bypass_sign_in(@admin)
      redirect_to action: 'index'
    else
      render "index"
    end
  end

  private

  def admin_params
    params.require(:admin).permit(:description, :password, :password_confirmation)
  end
end
