Class: WithAccounts::Jwts::AccessTokensCreating::FindAndCheckAccount

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

Instance Method Summary collapse

Methods included from ErrorsHelpers

#error_key, #format_errors

Instance Method Details

#instructions(stage) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/scenarios/with_accounts/jwts/access_tokens_creating/find_and_check_account.rb', line 7

def instructions(stage)
  unless stage.said.present?
    errors.add(error_key, 'err')
    return NOTHING_NEW
  end

  saved_72_char_version = stage.params[:refresh_token][0..71]

   = Account.joins(:user)
                   .where('users.disabled': false)
                   .find_by_said(stage.said)
                   &.authenticate_refresh_token(saved_72_char_version)

  unless 
    errors.add(error_key, 'err')
    return NOTHING_NEW
  end

  { account:  }
end