user events: let mods only see login/logout/signup events.

Adjust permissions on user events to let Moderators only see login,
logout, and user creation events, not other types of events (password
changes, etc). Admins can see everything. These other types of events
are meant for account security purposes and aren't very relevant for
sockpuppet detection purposes.
This commit is contained in:
evazion
2021-01-12 16:44:53 -06:00
parent be5cc3f99b
commit 7537edb211
2 changed files with 4 additions and 2 deletions

View File

@@ -22,8 +22,10 @@ class UserEvent < ApplicationRecord
delegate :country, :city, :is_proxy?, to: :ip_geolocation, allow_nil: true
def self.visible(user)
if user.is_moderator?
if user.is_admin?
all
elsif user.is_moderator?
where(category: [:login, :logout, :user_creation]).or(where(user: user))
else
where(user: user)
end

View File

@@ -1,5 +1,5 @@
class UserSessionPolicy < ApplicationPolicy
def index?
user.is_moderator?
user.is_admin?
end
end