class Api::ApiController < ActionController::API include TokenVerification helper_method :current_token, :current_login_employee, :get_cashier private #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON def current_token authenticate_with_http_token do |token, options| return token end end # Get current Cashier def get_cashier @cashier = Employee.where("role = 'cashier' AND token_session <> ''") end def current_login_employee @employee = Employee.find_by_token_session(current_token) end end