Sha256: 0c88736921a8ae5962ad8e0e6604dbe50e729ae50cbb6380ee1b92939cb965ff

Contents?: true

Size: 663 Bytes

Versions: 3

Compression:

Stored size: 663 Bytes

Contents

class Api::V1::ApiController < ::ActionController::API

  before_action :authenticate_user

  private

    def authenticate_user
      #["current_user","current_token"] Make this true to check for email also
      @instance_hash = ::Arcadex::Authentication.full_authentication(params,request,false)
      if @instance_hash.nil?
        render :json => {errors: "User is not logged in, register or log in"} , status: :unauthorized
      end
    end

    def current_user
    	if !@instance_hash.nil?
    		@instance_hash["current_user"]
    	end
    end

    def current_token
    	if !@instance_hash.nil?
    		@instance_hash["current_token"]
    	end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_voorhees-0.3.9 lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb
json_voorhees-0.3.6 lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb
json_voorhees-0.3.5 lib/generators/json_voorhees/setup_app/templates/api_controller_with_arcadex.rb