Table of Contents

Interface IUserService

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

The user store. Authorization is enforced in the service layer by AuthorizationUserServiceDecorator: resolving the current user and the invitation-accept name seeding are self-service; setting a display name is allowed on the caller's own record (otherwise users:manage); the [RequireScope]-annotated members document the scope they require.

public interface IUserService

Methods

ClearOwnIconAsync()

Clears the current user's own icon and deletes the stored bytes (self-service).

Task ClearOwnIconAsync()

Returns

Task

ClearUserIconAsync(string)

Clears a specific user's icon (administrative). Requires Manage.

[RequireScope("users:manage")]
Task ClearUserIconAsync(string userKey)

Parameters

userKey string

Returns

Task

DeleteUserAsync(string)

Deletes the user record from the store, with no team-membership cleanup — call through DeleteUserAsync(string, bool, CancellationToken), which removes team memberships and audits.

[RequireScope("users:manage")]
Task DeleteUserAsync(string userKey)

Parameters

userKey string

Returns

Task

GetAsync()

All users. Cross-user enumeration — requires Manage.

[RequireScope("users:manage")]
IAsyncEnumerable<IUser> GetAsync()

Returns

IAsyncEnumerable<IUser>

GetCurrentUserAsync(ClaimsPrincipal)

Task<IUser> GetCurrentUserAsync(ClaimsPrincipal claimsPrincipal = null)

Parameters

claimsPrincipal ClaimsPrincipal

Returns

Task<IUser>

GetTeamMemberUsersAsync()

The users who share at least one team with the caller, plus the caller themselves. Self-service: an authenticated caller is required but no scope, because the result is derived entirely from the caller's own team memberships and takes no argument that could widen it.

Task<IReadOnlyList<IUser>> GetTeamMemberUsersAsync()

Returns

Task<IReadOnlyList<IUser>>

Remarks

This is the identity source for the team member list when the caller lacks Manage. A member row's email, display name and icon live on the user record rather than on ITeamMember — accepting an invitation clears the per-team name override and promotes it to Name — so without this projection a team owner would see their own accepted members as unidentified. The default implementation returns an empty list; AuthorizationUserServiceDecorator supplies the real projection, as it holds the undecorated store.

GetUserByKeyAsync(string)

The user with the given key, or null. The default implementation scans GetAsync(); storage-backed services override it with a direct read.

[RequireScope("users:manage")]
Task<IUser> GetUserByKeyAsync(string userKey)

Parameters

userKey string

Returns

Task<IUser>

SeedUserNameAsync(string, string)

Sets the user's display name only if it is currently null/empty. Used by the invitation-accept flow to promote the admin-entered invitation name into the new user's identity without clobbering an IdP-provided name.

Task SeedUserNameAsync(string userKey, string name)

Parameters

userKey string
name string

Returns

Task

SetOwnIconAsync(byte[], string)

Sets the current user's own icon from raw image bytes (self-service): stores them via the registered IIconStore, persists the reference on the user, and deletes any previous icon. Requires a registered icon store and an authenticated caller.

Task SetOwnIconAsync(byte[] data, string contentType)

Parameters

data byte[]
contentType string

Returns

Task

SetUserDirectoryIdAsync(string, string)

Links the user to their external-directory id (DirectoryId). Called by the oid backfill (internal self-call) and by directory verification on an email-fallback match (relink). Default is a no-op — stores that track the directory id override it.

[RequireScope("users:manage")]
Task SetUserDirectoryIdAsync(string userKey, string directoryId)

Parameters

userKey string
directoryId string

Returns

Task

SetUserIconAsync(string, byte[], string)

Sets a specific user's icon (administrative). The mechanism is the same as SetOwnIconAsync(byte[], string) but targets userKey; requires Manage.

[RequireScope("users:manage")]
Task SetUserIconAsync(string userKey, byte[] data, string contentType)

Parameters

userKey string
data byte[]
contentType string

Returns

Task

SetUserLastSeenAsync(string, DateTime)

Stamps when the user last made an authenticated request. The automatic throttled stamping is an internal self-call that bypasses the authorization decorator; calling this member from outside requires Manage. The default is a no-op — stores that track LastSeen override it.

[RequireScope("users:manage")]
Task SetUserLastSeenAsync(string userKey, DateTime lastSeen)

Parameters

userKey string
lastSeen DateTime

Returns

Task

SetUserNameAsync(string, string)

Always sets the user's display name. Used by the user self-edit flow where the caller has explicitly chosen a name for themselves.

Task SetUserNameAsync(string userKey, string name)

Parameters

userKey string
name string

Returns

Task