2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
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
|
2018-04-11 15:03:05 -07:00
|
|
|
before_action :load_all_conferences
|
2014-08-13 14:37:05 +03:00
|
|
|
|
2017-06-24 05:03:24 +05:30
|
|
|
private
|
|
|
|
|
|
2018-04-11 15:03:05 -07:00
|
|
|
def load_all_conferences
|
|
|
|
|
@conferences = Conference.all
|
|
|
|
|
end
|
|
|
|
|
|
2017-06-24 05:03:24 +05:30
|
|
|
def current_ability
|
|
|
|
|
@current_ability ||= AdminAbility.new(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
2014-08-13 14:37:05 +03:00
|
|
|
def verify_user_admin
|
2025-08-12 17:59:47 +02:00
|
|
|
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
|
2018-03-28 17:31:18 -07:00
|
|
|
unless (current_user.has_cached_role? :organizer, :any) || (current_user.has_cached_role? :cfp, :any) ||
|
2024-06-07 16:19:29 +02:00
|
|
|
(current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :volunteers_coordinator, :any) ||
|
2018-03-28 17:31:18 -07:00
|
|
|
(current_user.has_cached_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
|
2025-08-12 17:59:47 +02:00
|
|
|
|
|
|
|
|
def sign_in_path
|
|
|
|
|
if ENV.fetch('OSEM_ICHAIN_ENABLED', nil) == 'true'
|
|
|
|
|
User.ichain_login_url
|
|
|
|
|
else
|
|
|
|
|
new_user_session_path
|
|
|
|
|
end
|
|
|
|
|
end
|
2014-08-13 14:37:05 +03:00
|
|
|
end
|
|
|
|
|
end
|