Class: SignIn::StatePayloadVerifier

Inherits:
Object
  • Object
show all
Defined in:
app/services/sign_in/state_payload_verifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state_payload:) ⇒ StatePayloadVerifier

Returns a new instance of StatePayloadVerifier.



7
8
9
# File 'app/services/sign_in/state_payload_verifier.rb', line 7

def initialize(state_payload:)
  @state_payload = state_payload
end

Instance Attribute Details

#state_payloadObject (readonly)

Returns the value of attribute state_payload.



5
6
7
# File 'app/services/sign_in/state_payload_verifier.rb', line 5

def state_payload
  @state_payload
end

Instance Method Details

#performObject



11
12
13
# File 'app/services/sign_in/state_payload_verifier.rb', line 11

def perform
  validate_state_code
end

#state_codeObject (private)



17
18
19
# File 'app/services/sign_in/state_payload_verifier.rb', line 17

def state_code
  @state_code ||= StateCode.find(state_payload.code)
end

#validate_state_codeObject (private)



21
22
23
24
25
# File 'app/services/sign_in/state_payload_verifier.rb', line 21

def validate_state_code
  raise Errors::StateCodeInvalidError.new message: 'Code in state is not valid' unless state_code
ensure
  state_code&.destroy
end