Table of Contents

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

user UserId

The user the credential belongs to.

credentialId Guid

The credential being written.

verifiedMaterial string

The record the request actually verified against, which the write is conditioned on.

material string

The stronger representation of the material already in use.

cancellationToken CancellationToken

Cancels 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 verifiedMaterial or material is null.

ArgumentException

Thrown when user names nobody or credentialId is the empty identifier.