Class: PinCodePolicy
- Includes:
- Base64
- Defined in:
- lib/models/pin_code_policy.rb
Overview
Pin code policy for this app
Instance Method Summary collapse
-
#enforce_policy(agent) ⇒ Object
return the policy hash for this agent.
Instance Method Details
#enforce_policy(agent) ⇒ Object
return the policy hash for this agent
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/models/pin_code_policy.rb', line 21 def enforce_policy(agent) policy = super.merge(pin_code_required: 0) return policy unless active? policy[:pin_code_required] = 1 policy[:pin_code_locked] = 0 policy[:pin_code_dialog_label] = dialog user = agent.find_user if user.present? if user.pin_code_locked? policy[:pin_code_locked] = 1 policy[:pin_code_message] = elsif user.pin_code.blank? policy[:pin_code_message] = else policy[:pin_code] = agent.encrypt_data(user.pin_code) policy[:pin_code_message] = policy[:pin_code_lock_after_failures] = lock_after_failures policy[:pin_code_session_hours] = session_hours end else policy[:pin_code_message] = end policy rescue StandardError => error log_error("Unable to build pin code policy for agent: #{agent.inspect} - #{inspect}", error) # Return the default policy { require_passcode: 0 } end |