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 AUTHED = %W{friend} def auth_action if current_user session.delete(:return_to) if session[:return_to] =~ /authed/ # FIXME: implement auth-action on a per-case basis redirect_to(client_url) and return else if AUTHED.include?(params[:authed]) session[:return_to] = auth_action_url(:authed => params[:authed], :data => params[:data]) else session.delete(:return_to) if session[:return_to] =~ /authed/ end redirect_to client_url end end end