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
ClearUserIconAsync(string)
Clears a specific user's icon (administrative). Requires Manage.
[RequireScope("users:manage")]
Task ClearUserIconAsync(string userKey)
Parameters
userKeystring
Returns
DeleteUserAsync(string)
[RequireScope("users:manage")]
Task DeleteUserAsync(string userKey)
Parameters
userKeystring
Returns
GetAsync()
All users. Cross-user enumeration — requires Manage.
[RequireScope("users:manage")]
IAsyncEnumerable<IUser> GetAsync()
Returns
GetCurrentUserAsync(ClaimsPrincipal)
Task<IUser> GetCurrentUserAsync(ClaimsPrincipal claimsPrincipal = null)
Parameters
claimsPrincipalClaimsPrincipal
Returns
GetCurrentUserAsync(ClaimsPrincipal, bool)
The user for claimsPrincipal, resolved as GetCurrentUserAsync(ClaimsPrincipal)
does, saying whether the resolve is the user being active.
Task<IUser> GetCurrentUserAsync(ClaimsPrincipal claimsPrincipal, bool recordActivity)
Parameters
claimsPrincipalClaimsPrincipalThe caller; null for the one on the current circuit.
recordActivityboolWhether this resolve counts towards LastSeen. Pass
falsefrom code that reads the user on a schedule rather than because they did something, such as claim revalidation on an idle tab.
Returns
Remarks
Only the last-seen stamp depends on it; keeping the record right from the sign-in (the directory id, a trusted profile refresh) happens either way. The default forwards to GetCurrentUserAsync(ClaimsPrincipal), so a host's own store keeps compiling and records whatever it recorded before.
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
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
userKeystring
Returns
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
Returns
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
Returns
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
Returns
SetUserDisabledAsync(string, DateTime?, 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 SetUserDisabledAsync(string userKey, DateTime? disabledAt, string disabledBy)
Parameters
Returns
Remarks
Throws rather than no-opping when unimplemented, for the same reason DeleteUserAsync(string) does: silently skipping a requested disable would hide the missing implementation behind an apparently successful containment.
SetUserEmailAsync(string, string)
Sets the user's email address (administrative). Call through SetUserEmailAsync(string, string, CancellationToken), which validates the address and audits the change; requires Manage.
[RequireScope("users:manage")]
Task SetUserEmailAsync(string userKey, string email)
Parameters
Returns
Remarks
Throws rather than no-opping when unimplemented, as SetUserDisabledAsync(string, DateTime?, string) does: silently skipping the change would report an address that was never set.
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
Returns
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
Returns
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)