diff --git a/app/models/ability.rb b/app/models/ability.rb index c1b61a4a9..743572488 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -29,8 +29,6 @@ class Ability else # Registered user rights if user.admin? can :manage, :all - # Resque authorize - can :manage, Resque # Protection cannot :approve, RegisterRequest, :approved => true cannot :reject, RegisterRequest, :rejected => true diff --git a/app/views/layouts/menu/_top.html.haml b/app/views/layouts/menu/_top.html.haml index 91539b90f..f74e0d84e 100644 --- a/app/views/layouts/menu/_top.html.haml +++ b/app/views/layouts/menu/_top.html.haml @@ -4,6 +4,4 @@ - if can? :index, base.to_s.classify.constantize %li= link_to title, send(:"#{namespace}#{base}_path"), :class => top_menu_class(base) - if current_user.try(:admin?) and which_menu == 'top_menu' - %li= link_to t('admins_menu_header'), admin_users_path, :class => top_menu_class('admin') - - if current_user.try(:admin?) and which_menu == 'admins_menu' - %li= link_to t('resque_server'), admin_resque_server_path + %li= link_to t('admins_menu_header'), admin_users_path, :class => top_menu_class('admin') \ No newline at end of file diff --git a/config/initializers/admin.rb b/config/initializers/admin.rb deleted file mode 100644 index 8ef8929ef..000000000 --- a/config/initializers/admin.rb +++ /dev/null @@ -1,8 +0,0 @@ -# config/initializers/admin.rb -class CanAccessResque - def self.matches?(request) - current_user = request.env['warden'].user - return false if current_user.blank? - Ability.new(current_user).can? :manage, Resque - end -end diff --git a/config/initializers/setup.rb b/config/initializers/setup.rb index 5aa0c8a1c..dd5406b31 100644 --- a/config/initializers/setup.rb +++ b/config/initializers/setup.rb @@ -12,3 +12,6 @@ Rosa::Application.config.middleware.insert_after ::Rails::Rack::Logger, ::Grack: Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Auth Rosa::Application.config.action_mailer.default_url_options = { :host => APP_CONFIG['action_mailer_host'] } if APP_CONFIG['action_mailer_host'] + +require 'resque/server' +::ResqueServer = ::Resque::Server # need for CanCan diff --git a/config/locales/menu.en.yml b/config/locales/menu.en.yml index 3ccc53713..b12e73c29 100644 --- a/config/locales/menu.en.yml +++ b/config/locales/menu.en.yml @@ -38,4 +38,4 @@ en: users: Users register_requests: Invites event_logs: Event log - resque_server: Resque + resque_server: Resque diff --git a/config/locales/menu.ru.yml b/config/locales/menu.ru.yml index 549300e00..6850b6b00 100644 --- a/config/locales/menu.ru.yml +++ b/config/locales/menu.ru.yml @@ -38,4 +38,4 @@ ru: users: Пользователи register_requests: Инвайты event_logs: Лог событий - resque_server: Resque + resque_server: Resque diff --git a/config/routes.rb b/config/routes.rb index 02abff2e0..569a0f939 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,5 @@ # -*- encoding : utf-8 -*- Rosa::Application.routes.draw do - require 'resque/server' - devise_scope :users do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' end @@ -24,10 +22,6 @@ Rosa::Application.routes.draw do end namespace :admin do - constraints CanAccessResque do - mount Resque::Server, at: 'resque' - end - resources :users do get :list, :on => :collection end @@ -39,6 +33,9 @@ Rosa::Application.routes.draw do end end resources :event_logs, :only => :index + constraints AdminAccess do + mount Resque::Server => 'resque' + end end resources :advisories, :only => [:index, :show] diff --git a/lib/ext/rails/owner_constraint.rb b/lib/ext/rails/constraints.rb similarity index 73% rename from lib/ext/rails/owner_constraint.rb rename to lib/ext/rails/constraints.rb index 10f091e3f..2ec8ef342 100644 --- a/lib/ext/rails/owner_constraint.rb +++ b/lib/ext/rails/constraints.rb @@ -10,3 +10,9 @@ class OwnerConstraint @class_name.send(@finder, request.params[:uname]).present? end end + +class AdminAccess + def self.matches?(request) + !!request.env['warden'].user.try(:admin?) + end +end