Class: WithAccounts::Jwts::RefreshTokensCreating::CheckLoginInvitation

Inherits:
LetsDoThis::Act
  • Object
show all
Includes:
ErrorsHelpers
Defined in:
app/scenarios/with_accounts/jwts/refresh_tokens_creating/check_login_invitation.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
27
28
# File 'app/scenarios/with_accounts/jwts/refresh_tokens_creating/check_login_invitation.rb', line 7

def instructions(stage)
   = stage.params[:invitation]
   = Account.joins(:user)
                   .where('users.disabled': false)
                   .()
  unless 
    errors.add(error_key, 'err')
    return NOTHING_NEW
  end

  encrypted = Base64.urlsafe_decode64()
  decipher = .cipher_decipher(:decrypt, :login_at)
  plain = decipher.update(encrypted) + decipher.final
  deadline = Time.at(plain.to_i)

  if Time.now > deadline
    errors.add(error_key, 'err')
    return NOTHING_NEW
  end

  { account:  }
end