docbrown/app/controllers/twilio_tokens_controller.rb
rhymes e588fa7ece Code cleanups (#659)
* Initial automatic cleanup with rubocop

* Fix syntax error introduced by rubocop

* Cleanup seeds file

* Cleanup lib folder

* Exclude bin folder because it contains auto generated files

* Make Rubocop a little bit more chatty

* Block length should not include comments in the count

* Cleanup config folder

* Cleanup specs

* Updated Rubocop version and generated a todo file

* Fix broken ArticlesApi spec

* Fix tests

* Restored rubocop pre-commit hook
2018-08-07 11:00:13 -04:00

16 lines
686 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