app/controllers/application_controller.rb
def api_admin_authorize
    api_cookie = cookies[:apiKey]
    puts '=======API COOKIE=========='
    puts api_cookie
    puts '==========================='
    @key = Key.find_by(:secret_key => api_cookie)
    if @key.nil? == true
      # redirect_to '/keys/noaccess'
      redirect_to '/admin/noaccess'
    elsif @key.nil? == false && @key.admin == false
      redirect_to '/admin/noaccess'
    end
  end
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception.
For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception . For APIs you may want to use : null_session instead .
def api_admin_authorize
    api_cookie = cookies[:apiKey]
    puts '=======API COOKIE=========='
    puts api_cookie
    puts '==========================='
    @key = Key.find_by(:secret_key => api_cookie)
    if @key.nil? == true
      redirect_to '/admin/noaccess'
    elsif @key.nil? == false && @key.admin == false
      redirect_to '/admin/noaccess'
    end
  end
def api_admin_authorize api_cookie = cookies [ :apiKey ] puts '=======API COOKIE==========' puts api_cookie puts '===========================' @key = Key . find_by ( :secret_key => api_cookie ) if @key . nil? == true redirect_to '/admin/noaccess' elsif @key . nil? == false && @key . admin == false redirect_to '/admin/noaccess' end end
Prevent CSRF attacks by raising an exception.
Prevent CSRF attacks by raising an exception .
# redirect_to '/keys/noaccess'