docbrown/app/controllers/video_chats_controller.rb
Ben Halpern efeef48df7
[deploy] Add authorization and new styles for sidecar video (#7120)
* Add authorization and new styles for sidecar video

* Launch sidecar with /call

* ensure html is string

* Add test for authorization
2020-04-06 21:43:41 -04:00

28 lines
755 B
Ruby

class VideoChatsController < ApplicationController
before_action :authenticate_user!
after_action :verify_authorized
def show
@chat_channel = ChatChannel.find(params[:id]) || not_found
authorize @chat_channel
account_sid = ApplicationConfig["TWILIO_ACCOUNT_SID"]
api_key = ApplicationConfig["TWILIO_VIDEO_API_KEY"]
api_secret = ApplicationConfig["TWILIO_VIDEO_API_SECRET"]
@username = "@" + current_user.username
token = Twilio::JWT::AccessToken.new(
account_sid,
api_key,
api_secret,
[],
identity: @username,
)
grant = Twilio::JWT::AccessToken::VideoGrant.new
grant.room = params[:id]
token.add_grant(grant)
@username = @username
@token = token.to_jwt
end
end