Interface RecoveryCodeRepository
public interface RecoveryCodeRepository
Port that stores the recovery codes of each user.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByUser(UUID userId) Deletes every code of a user.findUnused(UUID userId) Lists the codes of a user that have not been spent.booleanSpends a code, in one atomic step, so that two concurrent requests cannot both use it.voidreplaceAll(UUID userId, List<RecoveryCode> codes) Replaces every code of a user with a new set, which is what regenerating codes means.
-
Method Details
-
replaceAll
Replaces every code of a user with a new set, which is what regenerating codes means.- Parameters:
userId- identifier of the user.codes- the new codes.
-
findUnused
Lists the codes of a user that have not been spent.- Parameters:
userId- identifier of the user.- Returns:
- the unused codes, possibly empty.
-
markUsed
Spends a code, in one atomic step, so that two concurrent requests cannot both use it.- Parameters:
id- identifier of the code.now- instant of the use.- Returns:
truewhen the code was unused and is now spent.
-
deleteByUser
Deletes every code of a user.- Parameters:
userId- identifier of the user.
-