Module: Auth::Concerns::UserConcern::ClassMethods

Defined in:
app/models/auth/concerns/user_concern.rb

Instance Method Summary collapse

Instance Method Details

#find_resource(_id, resource) ⇒ Object

@param _id : the id sent into the request. @param resource : the currently signed in resource. how this works : it is called in the profiles_controller if the current signed in resource is admin, then whatever user_id(_id) was requested is searched and returned. if the current signed in resource is not admin, then _id is instead searched for using the current_signed_in_resource => basically will only return the user that is signed in.



364
365
366
367
368
369
370
371
372
# File 'app/models/auth/concerns/user_concern.rb', line 364

def find_resource(_id,resource)

	conditions = {:_id => _id}
	conditions[:_id] = resource.id.to_s if !resource.is_admin?
	all = self.where(conditions)
	
	return all.first if all.size > 0 
	return nil
end