Class: WithAccounts::Jwts::AccessTokensCreating::CheckRefreshToken

Inherits:
LetsDoThis::Act
  • Object
show all
Includes:
ErrorsHelpers
Defined in:
app/scenarios/with_accounts/jwts/access_tokens_creating/check_refresh_token.rb

Constant Summary collapse

HMAC_SECRET =
ENV.fetch('HMAC_SECRET', 'stemporalyasdasdasdasdasdjdhfjds').byteslice(0..31)

Instance Method Summary collapse

Methods included from ErrorsHelpers

#error_key, #format_errors

Instance Method Details

#instructions(stage) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/scenarios/with_accounts/jwts/access_tokens_creating/check_refresh_token.rb', line 8

def instructions(stage)
  refresh_token = stage.params[:refresh_token]
  decoded_token = JWT.decode(refresh_token,
                             HMAC_SECRET,
                             true,
                             { algorithm: 'HS256' })
  token_data = decoded_token.reduce({}, :merge)
  { said: token_data['said'] }
rescue JWT::DecodeError
  errors.add(error_key, 'err')
  NOTHING_NEW
end