Class: MHVMessagingPolicy
- Inherits:
-
Struct
- Object
- Struct
- MHVMessagingPolicy
- Defined in:
- app/policies/mhv_messaging_policy.rb
Instance Attribute Summary collapse
-
#mhv_messaging ⇒ Object
Returns the value of attribute mhv_messaging.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #access? ⇒ Boolean
- #log_denial_details ⇒ Object private
- #mobile_access? ⇒ Boolean
- #validate_client(client) ⇒ Object private
Instance Attribute Details
#mhv_messaging ⇒ Object
Returns the value of attribute mhv_messaging
5 6 7 |
# File 'app/policies/mhv_messaging_policy.rb', line 5 def mhv_messaging @mhv_messaging end |
#user ⇒ Object
Returns the value of attribute user
5 6 7 |
# File 'app/policies/mhv_messaging_policy.rb', line 5 def user @user end |
Instance Method Details
#access? ⇒ Boolean
6 7 8 9 10 11 |
# File 'app/policies/mhv_messaging_policy.rb', line 6 def access? return false unless user.mhv_correlation_id client = SM::Client.new(session: { user_id: user.mhv_correlation_id }) validate_client(client) end |
#log_denial_details ⇒ Object (private)
34 35 36 37 38 39 40 |
# File 'app/policies/mhv_messaging_policy.rb', line 34 def log_denial_details Rails.logger.info('SM ACCESS DENIED IN MOBILE POLICY', mhv_id: user.mhv_correlation_id.presence || 'false', sign_in_service: user.identity.sign_in[:service_name], va_facilities: user.va_treatment_facility_ids.length, va_patient: user.va_patient?) end |
#mobile_access? ⇒ Boolean
13 14 15 16 17 18 |
# File 'app/policies/mhv_messaging_policy.rb', line 13 def mobile_access? return false unless user.mhv_correlation_id client = Mobile::V0::Messaging::Client.new(session: { user_id: user.mhv_correlation_id }) validate_client(client) end |
#validate_client(client) ⇒ Object (private)
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/policies/mhv_messaging_policy.rb', line 22 def validate_client(client) if client.session.expired? client.authenticate !client.session.expired? else true end rescue log_denial_details false end |