class Api::V1::ApiController

Private Instance Methods

authenticate_app() click to toggle source
# File lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb, line 8
def authenticate_app
  api_key = ::Arcadex::Header.grab_param_header(params,request,::Settings.main_api_header,false)
  if api_key.nil? || api_key != ::Settings.main_api_key
    render :json => {errors: "App is not authorized"} , status: :forbidden
  end
end
authenticate_user() click to toggle source
# File lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb, line 15
def authenticate_user
  set_hash
  if @instance_hash.nil?
    response.headers["Logged-In-Status"] = "false"
    render :json => {errors: "User is not logged in, register or log in"} , status: :unauthorized
  else
    response.headers["Logged-In-Status"] = "true"
  end
end
current_token() click to toggle source
# File lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb, line 58
def current_token
  if !@instance_hash.nil?
    return @instance_hash["current_token"]
  else
    return nil
  end
end
current_user() click to toggle source
# File lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb, line 50
def current_user
  if !@instance_hash.nil?
    return @instance_hash["current_owner"]
  else
    return nil
  end
end
set_hash() click to toggle source
# File lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb, line 38
def set_hash
  #["current_owner","current_token"] Make this true to check for email also
  @instance_hash = ::Arcadex::Authentication.get_instance(params,request,::Settings.token_header)
  #@instance_hash = ::Arcadex::Authentication.authenticate_owner_with_index(params,request,"::Settings.token_header,"Email","email",true)
  #Ignore the token if the user's account is locked
  <% if !options.fbonly? %> 
  if !current_user.nil? && current_user.locked
    @instance_hash = nil
  end
  <% end %>
end