osem-fcy/app/controllers/api/v1/speakers_controller.rb
Rob Smith de4563ddb1 Remote forgery protection for json requests to the api/v1 endpoints
Due to my testing, I incorrectly removed the forgery protection
skip action from the controllers in the api. This fixes that and allows jsonp
calls to work correctly
2016-09-17 19:31:22 -07:00

23 lines
761 B
Ruby

module Api
module V1
class SpeakersController < Api::BaseController
load_resource :conference, find_by: :short_title
respond_to :json
# Disable forgery protection for any json requests. This is required for jsonp support
skip_before_action :verify_authenticity_token
def index
if @conference
users = User.joins(event_users: { event: { program: :conference} })
users = users.where(conferences: { short_title: @conference.short_title })
else
users = User.joins(:event_users)
end
users = users.where(event_users: {event_role: :speaker}).uniq
render json: users, each_serializer: SpeakerSerializer, callback: params['callback']
end
end
end
end