docbrown/app/controllers/twilio_tokens_controller.rb
Ben Halpern c60268b76f
Add pundit policy for several controllers (#476)
* Add pundit policy for several controllers

* Adjust video spec

* Fix tag request specs

* Add proper twilio tokens request specs

* Remove puts statements
2018-06-21 18:26:35 -04:00

16 lines
685 B
Ruby

class TwilioTokensController < ApplicationController
after_action :verify_authorized
def show
video_channel = params[:id].split("private-video-channel-")[1] if params[:id].start_with?("private-video-channel-")
unless video_channel
skip_authorization
render json: { status: "failure", token: @twilio_token }, status: 404
return
end
@chat_channel = ChatChannel.find(video_channel.to_i)
authorize @chat_channel #show pundit method for chat_channel_policy works here, should always check though
@twilio_token = TwilioToken.new(current_user, params[:id]).get
render json: { status: "success", token: @twilio_token }, status: 200
end
end