Class: WithAccounts::LoginInvitationsCreating::UpdateAccountLoginInvitation

Inherits:
LetsDoThis::Act
  • Object
show all
Includes:
ErrorsHelpers
Defined in:
app/scenarios/with_accounts/login_invitations_creating/update_account_login_invitation.rb

Instance Method Summary collapse

Methods included from ErrorsHelpers

#error_key, #format_errors

Instance Method Details

#instructions(stage) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/scenarios/with_accounts/login_invitations_creating/update_account_login_invitation.rb', line 6

def instructions(stage)
   = stage.
  data = (Time.now + Account::LOGIN_INVITATION_TTL).to_i.to_s

  cipher = .cipher_decipher(:encrypt, :login_at)

  encrypted = cipher.update(data) + cipher.final
  new_invitation = Base64.urlsafe_encode64(encrypted, padding: false)

  unless .update(login_invitation: new_invitation)
    errors.add(error_key, 'err')
    return NOTHING_NEW
  end

  { login_invitation: new_invitation }
end