diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb index 57ef069ec8eaeb4fed6e9f34cc85b73913b166b1..3c23cd7a01065d150da40489e9e0dc80adb56122 100644 --- a/config/initializers/resque.rb +++ b/config/initializers/resque.rb @@ -30,24 +30,6 @@ end if AppConfig[:mount_resque_web] require 'resque/server' - - class AdminRack - def initialize(app) - @app = app - end - - def call(env) - user = env['warden'].authenticate(:scope => :user) - if user && user.admin? - @app.call(env) - else - [307, {"Location" => '/'}, self] - end - end - - def each(&block) - end - end - + require File.join(Rails.root, 'lib/admin_rack') Resque::Server.use AdminRack end diff --git a/lib/admin_rack.rb b/lib/admin_rack.rb new file mode 100644 index 0000000000000000000000000000000000000000..39253b3d7ac3d251f0cbc79eaa3456074509a1f3 --- /dev/null +++ b/lib/admin_rack.rb @@ -0,0 +1,19 @@ +class AdminRack + def initialize(app) + @app = app + end + + def call(env) + user = env['warden'].authenticate(:scope => :user) + if user && user.admin? + @app.call(env) + else + [307, {"Location" => '/'}, self] + end + end + + def each(&block) + end +end + +