Class: AuthorizedUserPolicy

Inherits:
AppPolicy show all
Defined in:
lib/models/authorized_user_policy.rb

Overview

If this app requires an authorized user

Instance Method Summary collapse

Instance Method Details

#enforce_policy(agent) ⇒ Object

return the policy hash for this agent



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/models/authorized_user_policy.rb', line 15

def enforce_policy(agent)
  policy = super.merge(device_enabled: 1)
  if active? && !user_can_run_app?(agent)
    policy[:device_enabled] = 0
    policy[:device_disabled_message] = message
    policy[:wipe_app_data] = wipe_app_data
  end
  policy
rescue StandardError
  # Return the default policy
  { device_enabled: 1 }
end