Class: Jason::PusherController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/jason/pusher_controller.rb

Instance Method Summary collapse

Instance Method Details

#authObject



4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/jason/pusher_controller.rb', line 4

def auth
  channel_main_name = params[:channel_name].remove("private-#{Jason.pusher_channel_prefix}-")
  subscription_id = channel_main_name.remove('jason-')

  if Jason::Subscription.find_by_id(subscription_id).user_can_access?(current_user)
    response = Pusher.authenticate(params[:channel_name], params[:socket_id])
    return render json: response
  else
    return head :forbidden
  end
end