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
userUserIdThe user the credential belongs to.
credentialIdGuidThe credential being rotated.
usernameUserCredentialUsernameThe username the credential already carries, which a password rotation leaves where it is.
passwordReadOnlyMemory<char>The new plaintext, read within this call and never retained.
cancellationTokenCancellationTokenCancels 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
usernames nobody,credentialIdis the empty identifier,usernameis 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.