Method SetUserOrganizationAsync
- Namespace
- MailFathom.Application.Access.Organizations
- Assembly
- MailFathom.Application.dll
SetUserOrganizationAsync(UserId, Guid?, CancellationToken)
Moves a user into an organization, or out of every organization.
public Task<OrganizationWriteResult> SetUserOrganizationAsync(UserId user, Guid? organizationId, CancellationToken cancellationToken)
Parameters
userUserIdThe user being moved.
organizationIdGuid?The organization to move them into, or null to leave them in none.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<OrganizationWriteResult>
What the act did, carrying the colliding username where the target already holds one of theirs.
Remarks
Both sides have to be covered: the user where they stand now, and the organization they are moved into. Leaving every organization is a move into what only the deployment's scope covers, so only the deployment's scope writes it, and it is refused by name because it names no organization whose existence a refusal could disclose. A user outside the caller's scope is answered as unknown and an organization outside it as unknown, each the way the write answers one that does not exist.
Exceptions
- ArgumentException
Thrown when
usernames nobody, ororganizationIdis empty.- PrincipalNotAuthorizedException
Thrown when the caller holds AdminCredentialsWrite at no scope, or moves a user out of every organization without holding it over the whole deployment.