Sha256: c6b333c0a6bd1aecbce14e4e7c5a1ef461e1211cd8d36e8fb867d31f5289a7c1

Contents?: true

Size: 1.8 KB

Versions: 20

Compression:

Stored size: 1.8 KB

Contents

class Auth::SearchController < ApplicationController
		

	CONDITIONS_FOR_TOKEN_AUTH = [:authenticated_user_search]

	TCONDITIONS = {:only => CONDITIONS_FOR_TOKEN_AUTH}
	LAST_FALLBACK = :none

	include Auth::Concerns::DeviseConcern	
	include Auth::Concerns::TokenConcern

	before_action :do_before_request, TCONDITIONS

	## only option is to set no fallback
	## so that it will just go through.		
	## permitted_params[:query] is expected to be a hash, which can provide the following arguments
	## :query_string => a string for the query
	## :search_on_field => the field name on which the search can be performed, will default to the 'tags' field.
	## :size => the number of results to return, will default to 5.
	## @js erb -> renders html erb -> there each result class is detected and the requisite "_search.html.erb" partial is found for that class and rendered.
	## @json => authenticated_user_search.json is rendered.
	## @html => currently does not support html request.
	def authenticated_user_search	

		## remaining implementation is that a default as_json public has to be set to "no" for everything, and overriding it will be the job of the implementer to set it to "yes"
		## that way a filter is maintained.

		query = permitted_params[:query]

		if current_signed_in_resource
			if current_signed_in_resource.is_admin?
				query[:resource_is_admin] = true
			else
				query[:resource_id] = lookup_resource.id.to_s
			end
		end
		
		@search_results = Auth::Search::Main.search(query)
		
		@search_results.each do |res|
			if res.respond_to? :m_client
				res.m_client = self.m_client
			end
		end

		puts "these are the search results."
		@search_results.each do |result|
			puts result.to_s	
		end

		


		respond_with @search_results
	end



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


end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
wordjelly-auth-1.6.0 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.9 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.8 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.7 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.6 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.5 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.4 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.3 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.2 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.1 app/controllers/auth/search_controller.rb
wordjelly-auth-1.5.0 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.9 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.8 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.7 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.6 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.5 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.4 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.3 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.2 app/controllers/auth/search_controller.rb
wordjelly-auth-1.4.0 app/controllers/auth/search_controller.rb