Class: Auth::SearchController

Inherits:
ApplicationController show all
Includes:
Concerns::DeviseConcern, Concerns::TokenConcern
Defined in:
app/controllers/auth/search_controller.rb

Constant Summary collapse

CONDITIONS_FOR_TOKEN_AUTH =
[:authenticated_user_search]
TCONDITIONS =
{:only => CONDITIONS_FOR_TOKEN_AUTH}

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_resource!, #check_for_create, #check_for_destroy, #check_for_update, #from_bson, #from_view, #not_found

Instance Method Details

#authenticated_user_searchObject

rendering logic :



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/auth/search_controller.rb', line 28

def authenticated_user_search 
  
  ## m client will be available at this stage.
  ## the problem is that it is hard to pass it forward to the mongoid elasticsearch object.
  ## because while initializing the user it will have to first be set on the user.
  ## is there any other way to achieve this?
  query = permitted_params[:query]
  query[:resource_id] = lookup_resource.id.to_s if !current_signed_in_resource.is_admin?
  
  @search_results = Auth::Search::Main.search(query)
  
  puts "these are the search results."
  puts @search_results.to_s

  #dummy_product = Auth.configuration.product_class.constantize.new
  #dummy_product.name = "test product"
  #dummy_product.price = 100.20
  #@search_results = [dummy_product,dummy_product]
  @search_results.each do |res|
    if res.respond_to? :m_client
      res.m_client = self.m_client
    end
  end
  respond_with @search_results
end

#permitted_paramsObject



56
57
58
# File 'app/controllers/auth/search_controller.rb', line 56

def permitted_params
  params.permit({query: [:query_string, :size]})
end