docbrown/app/controllers/twilio_tokens_controller.rb
Anna Buianova 0ecb937875 Added rubocop-rails (#3059)
* Added rubocop-rails

* Update rubocop version in the CodeClimate config
2019-06-06 09:47:57 -04:00

16 lines
693 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: :not_found
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: :ok
end
end