class ApplicationController < ActionController::Base
  protect_from_forgery
  
  
  def authenticate_admin!
    
    if !current_admin
      redirect_to new_admin_auth_path
    end
      
    
  end
  
  
  private

    def current_admin
      if session[:admin_id] and Admin.exists?(session[:admin_id])
        @current_admin = Admin.find(session[:admin_id])
      else
        nil
      end
     
    end
    
  
    
    
    helper_method :current_admin
end
