diff --git a/app/controllers/admin/broadcast_announcements_controller.rb b/app/controllers/admin/broadcast_announcements_controller.rb index ea32fd7a32..ba0749cb7a 100644 --- a/app/controllers/admin/broadcast_announcements_controller.rb +++ b/app/controllers/admin/broadcast_announcements_controller.rb @@ -3,7 +3,7 @@ class Admin::BroadcastAnnouncementsController < AdminController before_action :require_admin def require_admin - verboten! unless current_user.has_role?(Role::SUPER_ADMIN) + verboten! unless current_user.has_cached_role?(Role::SUPER_ADMIN) end def index diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 4661e3f68b..d7e922009b 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -3,7 +3,7 @@ class AdminController < ApplicationController before_action :require_admin def require_admin - verboten! unless current_user.has_role?(Role::SUPER_ADMIN) + verboten! unless current_user.has_cached_role?(Role::SUPER_ADMIN) end def dashboard diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e80333a9ee..68779e92c3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -59,22 +59,21 @@ def dashboard_path_from_current_role def authorize_user return unless params[:controller] # part of omniauth controller flow verboten! unless params[:controller].include?("devise") || - current_user.has_role?(Role::SUPER_ADMIN) || - current_user.has_role?(Role::ORG_USER, current_organization) || - current_user.has_role?(Role::ORG_ADMIN, current_organization) || - current_user.has_role?(Role::PARTNER, current_partner) + current_user.has_cached_role?(Role::SUPER_ADMIN) || + current_user.has_cached_role?(Role::ORG_USER, current_organization) || + current_user.has_cached_role?(Role::ORG_ADMIN, current_organization) || + current_user.has_cached_role?(Role::PARTNER, current_partner) end def authorize_admin - verboten! unless current_user.has_role?(Role::SUPER_ADMIN) || - current_user.has_role?(Role::ORG_ADMIN, current_organization) + verboten! unless current_user.has_cached_role?(Role::SUPER_ADMIN) || + current_user.has_cached_role?(Role::ORG_ADMIN, current_organization) end def log_active_user if current_user && should_update_last_request_at? # we don't want the user record to validate or run callbacks when we're tracking activity current_user.update_columns(last_request_at: Time.now.utc) - end end diff --git a/app/controllers/distributions_controller.rb b/app/controllers/distributions_controller.rb index 98e4abd848..a9ebae8e54 100644 --- a/app/controllers/distributions_controller.rb +++ b/app/controllers/distributions_controller.rb @@ -177,7 +177,7 @@ def edit @distribution = Distribution.includes(:line_items).includes(:storage_location).find(params[:id]) @distribution.initialize_request_items if (!@distribution.complete? && @distribution.future?) || - current_user.has_role?(Role::ORG_ADMIN, current_organization) + current_user.has_cached_role?(Role::ORG_ADMIN, current_organization) @distribution.line_items.build if @distribution.line_items.size.zero? @items = current_organization.items.active.alphabetized @partner_list = current_organization.partners.alphabetized diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b10cbce8e1..cd19587561 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -81,8 +81,8 @@ def remove_user private def authorize_user - verboten! unless current_user.has_role?(Role::SUPER_ADMIN) || - current_user.has_role?(Role::ORG_USER, current_organization) + verboten! unless current_user.has_cached_role?(Role::SUPER_ADMIN) || + current_user.has_cached_role?(Role::ORG_USER, current_organization) end def organization_params @@ -121,7 +121,7 @@ def request_type_formatter(params) end def user_update_redirect_path - if current_user.has_role?(Role::SUPER_ADMIN) + if current_user.has_cached_role?(Role::SUPER_ADMIN) admin_organization_path(current_organization.id) else organization_path diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9c16d713ad..8c549c6624 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,7 +23,7 @@ def menu_open?(controller_action_names) end def can_administrate? - current_user.has_role?(Role::ORG_ADMIN, current_organization) + current_user.has_cached_role?(Role::ORG_ADMIN, current_organization) end def navigation_link_to(*args) diff --git a/app/views/distributions/show.html.erb b/app/views/distributions/show.html.erb index 040cba7f36..fe2b75ecca 100644 --- a/app/views/distributions/show.html.erb +++ b/app/views/distributions/show.html.erb @@ -83,7 +83,7 @@