Class: V0::VirtualAgent::JwtToken
Instance Method Summary
collapse
configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Instance Method Details
#body?(response) ⇒ Boolean
33
34
35
|
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 33
def body?(response)
response&.body && response.body.present?
end
|
#config ⇒ Object
19
20
21
|
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 19
def config
VAOS::Configuration.instance
end
|
#decoded_token(token) ⇒ Object
29
30
31
|
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 29
def decoded_token(token)
JWT.decode(token, nil, false).first
end
|
25
26
27
|
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 25
def
{ 'Accept' => 'text/plain', 'Content-Type' => 'text/plain', 'Referer' => referrer }
end
|
#new_jwt_token(user) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 6
def new_jwt_token(user)
url = '/users/v2/session?processRules=true'
token = VAOS::JwtWrapper.new(user).token
response = perform(:post, url, token, )
Rails.logger.info('Chatbot JWT session created',
{ account_uuid: user.account_uuid, jti: decoded_token(token)['jti'] })
response.body
end
|
#referrer ⇒ Object
37
38
39
40
41
42
43
|
# File 'app/controllers/v0/virtual_agent/jwt_token.rb', line 37
def referrer
if Settings.hostname.ends_with?('.gov')
"https://#{Settings.hostname}".gsub('vets', 'va')
else
'https://review-instance.va.gov' end
end
|