Method ReplaceMaterialAsync
- Namespace
- MailFathom.Application.Access.Credentials
- Assembly
- MailFathom.Application.dll
ReplaceMaterialAsync(UserId, Guid, UserCredentialMethod, UserCredentialLookup, string?, CancellationToken)
Replaces what one credential is presented as, leaving its user, its identifier, and its grant where they are.
Task<UserCredentialWriteOutcome> ReplaceMaterialAsync(UserId user, Guid credentialId, UserCredentialMethod method, UserCredentialLookup lookup, string? material, CancellationToken cancellationToken)
Parameters
userUserIdThe user the credential belongs to.
credentialIdGuidThe credential being written.
methodUserCredentialMethodThe method the credential must already carry, so a rotation cannot land on a credential of another kind.
lookupUserCredentialLookupThe value it is resolved by from now on, which is unchanged for a password and new for a key.
materialstringThe stored representation of the new material, or null for a method that keeps none.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<UserCredentialWriteOutcome>
What the act did, or why it did nothing.
Remarks
One statement, so the old material is never absent and never present beside the new one: a request arriving while the replacement commits is judged against exactly one of the two, and the previous credential stops working the moment the transaction does. The instant the credential reports its material as having changed at moves with it.
Exceptions
- ArgumentException
Thrown when
usernames nobody,credentialIdis the empty identifier, ormethodorlookupis the unspecified struct default.