jam-cloud/web/app/controllers/clients_controller.rb

43 lines
1.5 KiB
Ruby

class ClientsController < ApplicationController
include UsersHelper
def index
# we want to enforce that /client is always the client view prefix
# this is a side effect of setting root path to '/'; soon we can remove this when we implement the new home page
if request.path == '/'
redirect_to client_url
return
end
# use gon to pass variables into javascript
gon.websocket_gateway_uri = Rails.application.config.websocket_gateway_uri
gon.check_for_client_updates = Rails.application.config.check_for_client_updates
gon.fp_apikey = Rails.application.config.filepicker_rails.api_key
gon.fp_upload_dir = Rails.application.config.filepicker_upload_dir
gon.allow_force_native_client = Rails.application.config.allow_force_native_client
# is this the native client or browser?
user_agent = request.env["HTTP_USER_AGENT"]
@nativeClient = !user_agent.blank? && user_agent.downcase.include?("jamkazam")
# allow override of the client type if configured to so, and if we find the override cookie in place
if Rails.application.config.allow_force_native_client
unless cookies[:act_as_native_client].nil?
@nativeClient = (cookies[:act_as_native_client] == "true") ? true : false
end
end
# let javascript have access to the server's opinion if this is a native client
gon.isNativeClient = @nativeClient
if current_user
render :layout => 'client'
else
redirect_to "/signin"
end
end
end