class

KemalIdentity::Testing::MemoryActionTokenRepository

Inherits KemalIdentity::Accounts::ActionTokenRepository < Reference < Object

In-memory Accounts::ActionTokenRepository.

Passes the same contract spec as the PostgreSQL adapter. The atomicity the contract demands comes from a mutex here and from a conditional update there; the contract does not care which, only that exactly one concurrent caller wins.

Constructors

Instance methods

The whole lookup, the expiry check, the purpose check and the write happen inside one critical section. Splitting them would let two callers both observe an unused token.

Source

Stores a newly issued token.

Raises KemalIdentity::InfrastructureError if the digest is already present. As with sessions, the unique index exists so that a collision is a loud error rather than two grants sharing a secret.

Source
delete_expired(before : Time) : Int32

Deletes rows past their expiry, returning the count.

Disk reclamation only. Correctness never depends on it: expiry is evaluated inside #consume.

Source
revoke_all_for_account(account_id : String, purpose : KemalIdentity::Accounts::ActionPurpose, at : Time) : Int32

Marks every outstanding token of this purpose for this account as used, returning how many it spent.

Issuing a new reset link invalidates the previous ones, so a link sitting in an old email — or in an inbox somebody else now controls — stops working. Also the right response to a completed password change.

Source
size
Source