From b5118dd80a011d9bc520b2affcc921887388d9a7 Mon Sep 17 00:00:00 2001 From: Matt Moriarity Date: Fri, 27 Jul 2007 23:38:16 -0400 Subject: [PATCH] Authentication is still not quite working I'm putting the work on it on hold until I have time to figure why it sucks --- app/controllers/application.rb | 4 ---- app/controllers/slingshot_sync_controller.rb | 14 +++++++++----- lib/authenticated_system.rb | 5 ++++- .../lib/app/controllers/slingshot_controller.rb | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 267f237..09c2603 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -11,8 +11,4 @@ class ApplicationController < ActionController::Base # If you want "remember me" functionality, add this before_filter to Application Controller before_filter :login_from_cookie before_filter :login_required - - def offline? - (ENV['OFFLINE_MODE']) ? (ENV['OFFLINE_MODE'] == 'true') : false - end end diff --git a/app/controllers/slingshot_sync_controller.rb b/app/controllers/slingshot_sync_controller.rb index 9a9e769..3dced17 100644 --- a/app/controllers/slingshot_sync_controller.rb +++ b/app/controllers/slingshot_sync_controller.rb @@ -11,6 +11,7 @@ class SlingshotSyncController < SlingshotController + include AuthenticatedSystem before_filter :require_http_authentication # Here is where the bulk of your efffort will go in the down sync portion @@ -21,9 +22,13 @@ class SlingshotSyncController < SlingshotController # allowed access to your service. def aggregate_data model = [current_user] - model += current_user.songs - model += current_user.shows - model += current_user.usages + model += Song.find(:all, :conditions => ["user_id = ?", current_user.id]) + model += Show.find(:all, :conditions => ["user_id = ?", current_user.id]) + current_user.shows.each do |s| + model += s.usages + end + puts model.inspect + model end # @@ -41,13 +46,12 @@ class SlingshotSyncController < SlingshotController def require_http_authentication - return true # Use this to hook into your authentication unless (auth = (request.env['X-HTTP_AUTHORIZATION'] || request.env['HTTP_AUTHORIZATION'])).nil? auth = auth.split user, password = Base64.decode64(auth[1]).split(':')[0..1] - self.current_user = User.authenticate_user(user,password) + self.current_user = User.authenticate(user,password) if logged_in? return true end diff --git a/lib/authenticated_system.rb b/lib/authenticated_system.rb index cd77fc5..dc8795b 100644 --- a/lib/authenticated_system.rb +++ b/lib/authenticated_system.rb @@ -1,5 +1,8 @@ module AuthenticatedSystem protected + def offline? + (ENV['OFFLINE_MODE']) ? (ENV['OFFLINE_MODE'] == 'true') : false + end # Returns true or false if the user is logged in. # Preloads @current_user with the user model if they're logged in. def logged_in? @@ -101,7 +104,7 @@ module AuthenticatedSystem # Inclusion hook to make #current_user and #logged_in? # available as ActionView helper methods. def self.included(base) - base.send :helper_method, :current_user, :logged_in? + base.send :helper_method, :current_user, :logged_in?, :offline? end # When called with before_filter :login_from_cookie will check for an :auth_token diff --git a/vendor/plugins/slingshot_plugin/lib/app/controllers/slingshot_controller.rb b/vendor/plugins/slingshot_plugin/lib/app/controllers/slingshot_controller.rb index d70bca8..31f6f9f 100644 --- a/vendor/plugins/slingshot_plugin/lib/app/controllers/slingshot_controller.rb +++ b/vendor/plugins/slingshot_plugin/lib/app/controllers/slingshot_controller.rb @@ -127,7 +127,7 @@ class SlingshotController < ActionController::Base data_packet = aggregate_data - + if full_sync == 'yes' append_xml(data_packet, filterDate, :full_sync) append_csv(data_packet) -- 2.11.4.GIT