Class: LoginActivityPolicy

Inherits:
ApplicationPolicy show all
Defined in:
lib/kowl/templates/app/policies/login_activity_policy.rb

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#current_user, #record

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#admin?, #initialize, #staff?, #staff_member?

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 24

def create?
  edit?
end

#destroy?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 32

def destroy?
  edit?
end

#edit?Boolean

All audit logs should not be modifiable, by any means

Returns:

  • (Boolean)


16
17
18
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 16

def edit?
  false
end

#index?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 11

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

#new?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 20

def new?
  edit?
end

#show?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 4

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

#update?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/kowl/templates/app/policies/login_activity_policy.rb', line 28

def update?
  edit?
end