Class: WithAccounts::Jwts::RefreshTokensCreating::CheckLoginInvitation
- Inherits:
-
LetsDoThis::Act
- Object
- LetsDoThis::Act
- WithAccounts::Jwts::RefreshTokensCreating::CheckLoginInvitation
show all
- Includes:
- ErrorsHelpers
- Defined in:
- app/scenarios/with_accounts/jwts/refresh_tokens_creating/check_login_invitation.rb
Instance Method Summary
collapse
#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)
login_invitation = stage.params[:invitation]
account = Account.joins(:user)
.where('users.disabled': false)
.find_by_login_invitation(login_invitation)
unless account
errors.add(error_key, 'err')
return NOTHING_NEW
end
encrypted = Base64.urlsafe_decode64(login_invitation)
decipher = account.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: account }
end
|