Table of Contents

Class AuditingUserManagementServiceDecorator

Namespace
Tharga.Team.Service.Audit
Assembly
Tharga.Team.Service.dll

Decorator that wraps IUserManagementService and logs audit entries for user administration: per-user verification (with outcome), bulk verification (one summary entry), and deletion (with team count and directory result). The directory-only listing is a read with no side effect and is not audited, consistent with team enumeration.

public class AuditingUserManagementServiceDecorator : IUserManagementService
Inheritance
AuditingUserManagementServiceDecorator
Implements
Inherited Members

Constructors

AuditingUserManagementServiceDecorator(IUserManagementService, CompositeAuditLogger, IHttpContextAccessor)

public AuditingUserManagementServiceDecorator(IUserManagementService inner, CompositeAuditLogger auditLogger, IHttpContextAccessor httpContextAccessor)

Parameters

inner IUserManagementService
auditLogger CompositeAuditLogger
httpContextAccessor IHttpContextAccessor

Methods

DeleteUserAsync(string, bool, CancellationToken)

Delete a user: removes the user from every team and deletes the user record (audited). With deleteFromDirectory the user is also deleted from the external directory; a directory failure does not roll back the local delete — it is reported on the result.

public Task<UserDeleteResult> DeleteUserAsync(string userKey, bool deleteFromDirectory = false, CancellationToken cancellationToken = default)

Parameters

userKey string
deleteFromDirectory bool
cancellationToken CancellationToken

Returns

Task<UserDeleteResult>

GetDirectoryOnlyUsersAsync(CancellationToken)

List directory users that have no matching local user (matched by directory id, falling back to email), streamed as directory pages arrive.

public IAsyncEnumerable<DirectoryUser> GetDirectoryOnlyUsersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

IAsyncEnumerable<DirectoryUser>

GetOwnedTeamsAsync(string, CancellationToken)

public Task<IReadOnlyList<ITeam>> GetOwnedTeamsAsync(string userKey, CancellationToken cancellationToken = default)

Parameters

userKey string
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<ITeam>>

Remarks

A read that runs when a delete confirmation opens, so it is not audited — logging it would record an entry for looking at a dialog the operator may then cancel. The delete it precedes is audited.

SetUserDisabledAsync(string, bool, CancellationToken)

public Task SetUserDisabledAsync(string userKey, bool disabled, CancellationToken cancellationToken = default)

Parameters

userKey string
disabled bool
cancellationToken CancellationToken

Returns

Task

Remarks

Both directions, under distinct actions — disable is a containment, enable is a decision to let the person back in. One entry keyed on a boolean would make "who re-enabled this" a query rather than a reading. The refusal to disable oneself is audited as a failure too: an administrator repeatedly trying it is worth seeing.

SetUserNameAsync(string, string, CancellationToken)

public Task<UserNameChangeResult> SetUserNameAsync(string userKey, string name, CancellationToken cancellationToken = default)

Parameters

userKey string
name string
cancellationToken CancellationToken

Returns

Task<UserNameChangeResult>

Remarks

The directory outcome is recorded rather than just the local write: a rename that succeeded here and failed there is the case someone will later need to explain, and it is invisible otherwise.

VerifyAllAsync(CancellationToken)

Verify all local users against the external directory, streamed as results arrive.

public IAsyncEnumerable<UserVerificationResult> VerifyAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

IAsyncEnumerable<UserVerificationResult>

VerifyUserAsync(string, CancellationToken)

Verify a local user against the external directory. When the user resolves via email fallback, the found directory id is persisted on the user (relink).

public Task<DirectoryVerificationResult> VerifyUserAsync(string userKey, CancellationToken cancellationToken = default)

Parameters

userKey string
cancellationToken CancellationToken

Returns

Task<DirectoryVerificationResult>