Sha256: 241d8b29566220b240e019b943ce6715e6d135c6672f43ff0b07e99d32c4c21a

Contents?: true

Size: 766 Bytes

Versions: 7

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

class LoginActivityPolicy < ApplicationPolicy
  def show?
    # Only display all login activity if the current user is an admin
    # => Otherwise if the user is a staff member, only display login activity for everyone who isn't an admin
    # => If somehow a user hits this page, only allow them to see login activity for themselves
    admin? || (staff? && record.user.role != 'superuser') || (staff_member? && current_user.id == record.user_id)
  end

  def index?
    admin? || current_user.id == record.user_id
  end

  # All audit logs should not be modifiable, by any means
  def edit?
    false
  end

  def new?
    edit?
  end

  def create?
    edit?
  end

  def update?
    edit?
  end

  def destroy?
    edit?
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kowl-0.0.7 lib/kowl/templates/app/policies/login_activity_policy.rb
kowl-0.0.6 lib/kowl/templates/app/policies/login_activity_policy.rb
kowl-0.0.5 lib/kowl/templates/app/policies/login_activity_policy.rb
kowl-0.0.4 lib/kowl/templates/app/policies/login_activity_policy.rb
kowl-0.0.3 lib/kowl/templates/app/policies/login_activity_policy.rb
kowl-0.0.2 lib/kowl/templates/app/policies/login_activity_policy.rb
kowl-0.0.1 lib/kowl/templates/app/policies/login_activity_policy.rb