osem-fcy/app/controllers/admin/base_controller.rb
2018-04-04 10:28:10 -07:00

26 lines
868 B
Ruby

# frozen_string_literal: true
module Admin
class BaseController < ApplicationController
before_action :verify_user_admin
private
def current_ability
@current_ability ||= AdminAbility.new(current_user)
end
def verify_user_admin
if current_user.nil?
redirect_to sign_in_path
return false
end
unless (current_user.has_cached_role? :organizer, :any) || (current_user.has_cached_role? :cfp, :any) ||
(current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :organization_admin, :any) ||
(current_user.has_cached_role? :volunteers_coordinator, :any) ||
(current_user.has_cached_role? :track_organizer, :any) || current_user.is_admin
raise CanCan::AccessDenied, 'You are not authorized to access this page.'
end
end
end
end