Class: SelfAuthResponseManagerService
- Inherits:
-
Object
- Object
- SelfAuthResponseManagerService
- Defined in:
- app/services/self_auth_response_manager_service.rb
Overview
Manages self authentication responses
Constant Summary collapse
- STATUS_ERR =
'errored'.freeze
- STATUS_REJ =
'rejected'.freeze
- STATUS_OK =
'accepted'.freeze
- STATUS_COM =
'completed'.freeze
- STATUS_RECIEVED =
'received'.freeze
Instance Method Summary collapse
-
#initialize(broadcaster) ⇒ SelfAuthResponseManagerService
constructor
A new instance of SelfAuthResponseManagerService.
-
#process_response(self_auth_response) ⇒ Object
Processes a Self authentication response.
Constructor Details
#initialize(broadcaster) ⇒ SelfAuthResponseManagerService
Returns a new instance of SelfAuthResponseManagerService.
9 10 11 |
# File 'app/services/self_auth_response_manager_service.rb', line 9 def initialize(broadcaster) @broadcaster = broadcaster end |
Instance Method Details
#process_response(self_auth_response) ⇒ Object
Processes a Self authentication response
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/self_auth_response_manager_service.rb', line 14 def process_response(self_auth_response) return if self_auth_response.nil? cid = self_auth_response.id.split('_').first.split('::').last channel = "conversation_#{cid}_channel" if self_auth_response.errored? broadcast_status_change channel, STATUS_ERR, message: 'A timeout ocured while waiting for your device response' return end if self_auth_response.rejected? broadcast_status_change channel, STATUS_REJ return end unless SelfAuthRails.permitted_auth.call(self_auth_response.from) broadcast_status_change channel, STATUS_ERR, message: 'You are forbidden to access this service' return end user = set_user_token(self_auth_response.from, self_auth_response) broadcast_status_change channel, STATUS_COM, token: user[:token] end |