2014-08-13 14:37:05 +03:00
|
|
|
module Admin
|
|
|
|
|
class BaseController < ApplicationController
|
2017-09-05 22:23:34 +03:00
|
|
|
before_action :verify_user_admin
|
2014-08-13 14:37:05 +03:00
|
|
|
|
2017-06-24 05:03:24 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def current_ability
|
|
|
|
|
@current_ability ||= AdminAbility.new(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
2014-08-13 14:37:05 +03:00
|
|
|
def verify_user_admin
|
|
|
|
|
if (current_user.nil?)
|
2014-11-12 10:20:53 +01:00
|
|
|
redirect_to sign_in_path
|
2014-08-13 14:37:05 +03:00
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
unless (current_user.has_role? :organizer, :any) || (current_user.has_role? :cfp, :any) ||
|
2017-06-13 04:39:47 +05:30
|
|
|
(current_user.has_role? :info_desk, :any) || (current_user.has_role? :organization_admin, :any) ||
|
2017-06-08 12:25:33 +03:00
|
|
|
(current_user.has_role? :volunteers_coordinator, :any) ||
|
|
|
|
|
(current_user.has_role? :track_organizer, :any) || current_user.is_admin
|
2017-06-14 20:42:50 +05:30
|
|
|
raise CanCan::AccessDenied.new('You are not authorized to access this page.')
|
2014-08-13 14:37:05 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|