Interface IUserRepository
- Namespace
- SEBT.Portal.Core.Repositories
- Assembly
- SEBT.Portal.Core.dll
Repository interface for managing user data and ID proofing status.
public interface IUserRepository
Methods
CreateUserAsync(User, CancellationToken)
Creates a new user record.
Task CreateUserAsync(User user, CancellationToken cancellationToken = default)
Parameters
userUserThe user to create.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task
A task representing the asynchronous operation.
GetOrCreateUserAsync(string, CancellationToken)
Gets or creates a user by email. If the user doesn't exist, creates a new one.
Task<(User user, bool isNewUser)> GetOrCreateUserAsync(string email, CancellationToken cancellationToken = default)
Parameters
emailstringThe email address of the user.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<(User user, bool isNewUser)>
A tuple containing the existing or newly created user and a boolean indicating if the user was newly created.
GetOrCreateUserByExternalIdAsync(string, string?, CancellationToken)
Gets or creates a user by their external identity provider subject ID. Used for OIDC-authenticated users whose identity is anchored by the IdP's sub claim. Creates a minimal record (no email, no IAL) — those attributes come from IdP claims.
When email is provided and no user exists for the given
externalProviderId, falls back to an email-based lookup and
adopts that record by setting its ExternalProviderId. This migrates pre-existing
email-only user records to the new sub-based identity model.
TODO: Remove email fallback migration once all existing users have logged in
under the new flow.
Task<(User user, bool isNewUser)> GetOrCreateUserByExternalIdAsync(string externalProviderId, string? email = null, CancellationToken cancellationToken = default)
Parameters
externalProviderIdstringemailstringcancellationTokenCancellationToken
Returns
- Task<(User user, bool isNewUser)>
GetUserByEmailAsync(string, CancellationToken)
Retrieves a user by their email address.
Task<User?> GetUserByEmailAsync(string email, CancellationToken cancellationToken = default)
Parameters
emailstringThe email address of the user.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<User>
The user if found; otherwise,
null.
GetUserByExternalIdAsync(string, CancellationToken)
Retrieves a user by their external identity provider subject ID.
Task<User?> GetUserByExternalIdAsync(string externalProviderId, CancellationToken cancellationToken = default)
Parameters
externalProviderIdstringcancellationTokenCancellationToken
Returns
- Task<User>
GetUserByIdAsync(Guid, CancellationToken)
Retrieves a user by their database primary key.
Task<User?> GetUserByIdAsync(Guid id, CancellationToken cancellationToken = default)
Parameters
idGuidThe user's ID.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<User>
The user if found; otherwise,
null.
GetUserBySessionIdAsync(string, CancellationToken)
Retrieves a user by their ID proofing session ID.
Task<User?> GetUserBySessionIdAsync(string sessionId, CancellationToken cancellationToken = default)
Parameters
sessionIdstringThe session ID from the proofing provider.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<User>
The user if found; otherwise,
null.
UpdateUserAsync(User, CancellationToken)
Updates an existing user record.
Task UpdateUserAsync(User user, CancellationToken cancellationToken = default)
Parameters
userUserThe user to update.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task
A task representing the asynchronous operation.