class ClientsController < ApplicationController

  include UsersHelper

  def index
    # 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

    if current_user
        render :layout => 'client'
    else
        redirect_to "/signin"
    end
  end

end
