Method RewriteMaterialAsync
- Namespace
- MailFathom.Application.Access.Credentials
- Assembly
- MailFathom.Application.dll
RewriteMaterialAsync(UserId, Guid, string, string, CancellationToken)
Rewrites the stored record of material that has not changed.
Task<UserCredentialWriteOutcome> RewriteMaterialAsync(UserId user, Guid credentialId, string verifiedMaterial, string material, CancellationToken cancellationToken)
Parameters
userUserIdThe user the credential belongs to.
credentialIdGuidThe credential being written.
verifiedMaterialstringThe record the request actually verified against, which the write is conditioned on.
materialstringThe stronger representation of the material already in use.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<UserCredentialWriteOutcome>
What the act did, or why it did nothing.
Remarks
The one operation an authenticated request performs on a credential, and it is separate from ReplaceMaterialAsync(UserId, Guid, UserCredentialMethod, UserCredentialLookup, string?, CancellationToken) for one reason: the material did not change, so the instant the credential reports its material as having changed at must not move. Reporting every user who signed in after the work parameters rose as having just chosen a new password would make that column useless for the question it exists to answer.
It writes only over the record it verified against. The request that reaches here read the
stored record, spent a deliberately slow derivation verifying it, and spent another producing the replacement,
and an administrator rotating a leaked credential can commit inside that window — which is the case rotation
exists for. A rehash that named the credential alone would put the superseded material back and stop the
replacement working, silently, on a path that never fails the request. Naming
verifiedMaterial makes the write lose that race instead, answering
UnknownCredential so the rehash is dropped and the rotation stands.
Exceptions
- ArgumentNullException
Thrown when
verifiedMaterialormaterialis null.- ArgumentException
Thrown when
usernames nobody orcredentialIdis the empty identifier.