Table of Contents

Method RotatePasswordAsync

Namespace
MailFathom.Application.Access.Credentials
Assembly
MailFathom.Application.dll

RotatePasswordAsync(UserId, Guid, UserCredentialUsername, ReadOnlyMemory<char>, CancellationToken)

Replaces one credential's password, which stops the previous one working at that instant.

public Task<UserCredentialRotation> RotatePasswordAsync(UserId user, Guid credentialId, UserCredentialUsername username, ReadOnlyMemory<char> password, CancellationToken cancellationToken)

Parameters

user UserId

The user the credential belongs to.

credentialId Guid

The credential being rotated.

username UserCredentialUsername

The username the credential already carries, which a password rotation leaves where it is.

password ReadOnlyMemory<char>

The new plaintext, read within this call and never retained.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<UserCredentialRotation>

What the act did, or why it did nothing.

Remarks

The username is stated rather than read back first, because the write names the lookup a credential carries from now on and a password rotation is the one case where that is the value it already had; a mistyped one answers that no such credential exists rather than renaming somebody's sign-in.

Exceptions

ArgumentException

Thrown when user names nobody, credentialId is the empty identifier, username is the unspecified struct default, or the password breaks UserPasswordPolicy.

PrincipalNotAuthorizedException

Thrown when the caller holds AdminCredentialsWrite at no scope, does not hold a name the user holds widely enough, or is not the root while the user holds a role listing a pattern.