diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d95db2..96b5dfe 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,13 @@ class ApplicationController < ActionController::Base # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. allow_browser versions: :modern + + before_action :set_current + + private + def set_current + Current.user_agent = request.user_agent + Current.ip_address = request.ip + Current.session = Profile.find_by_id(cookies.signed[:profile_id]) + end end diff --git a/app/models/current.rb b/app/models/current.rb new file mode 100644 index 0000000..2e2a115 --- /dev/null +++ b/app/models/current.rb @@ -0,0 +1,4 @@ +class Current < ActiveSupport::CurrentAttributes + attribute :session + attribute :user_agent, :ip_address +end diff --git a/app/policies/badge_class_policy.rb b/app/policies/badge_class_policy.rb index 88f8dbe..1c4270a 100644 --- a/app/policies/badge_class_policy.rb +++ b/app/policies/badge_class_policy.rb @@ -15,7 +15,7 @@ def manage? end def send? - if @badge_class.group_id && @badge_class.permissions.include?("group_member_send") + if @badge_class.group_id && @badge_class.permissions["group_member_send"] @badge_class.group.is_member(@profile.id) elsif @badge_class.group_id @badge_class.group.is_manager(@profile.id)