Class UserLoginStore
Azure Cosmos DB implementation of the user login store, managing external login credentials for users.
Implements
Inherited Members
Namespace: DataWeb.Identity.AzureCosmosDB
Assembly: DataWeb.Data.AzureCosmosDB.dll
Syntax
public class UserLoginStore : IUserLoginStore
Remarks
Provides methods to manage user logins with external providers, including:
- Query logins by user ID, provider key, or login provider
- Add new external login credentials
- Remove specific or all logins for a user Data is stored in sys_userlogins container with parametrized queries for injection protection.
Constructors
UserLoginStore(ICosmosHelper, IConfigurationService)
Azure Cosmos DB implementation of the user login store, managing external login credentials for users.
Declaration
public UserLoginStore(ICosmosHelper cosmosHelper, IConfigurationService configurationService)
Parameters
| Type | Name | Description |
|---|---|---|
| ICosmosHelper | cosmosHelper | |
| IConfigurationService | configurationService |
Remarks
Provides methods to manage user logins with external providers, including:
- Query logins by user ID, provider key, or login provider
- Add new external login credentials
- Remove specific or all logins for a user Data is stored in sys_userlogins container with parametrized queries for injection protection.
Properties
Name
Gets the name of the store implementation.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
AddAsync(string, string, string, CancellationToken)
Adds a new external login credential for a user.
Declaration
public Task AddAsync(string userIdMaster, string providerKey, string loginProvider, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userIdMaster | The user ID. Must not be null or empty. |
| string | providerKey | The external provider key. Must not be null or empty. |
| string | loginProvider | The name of the login provider (e.g., 'Google', 'Facebook'). Must not be null or empty. |
| CancellationToken | cancellationToken | Cancellation token for the async operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when any parameter is null or empty. |
GetLoginAsync(UserLoginFilter, CancellationToken)
Retrieves a single user login credential based on the provided filter criteria.
Declaration
public Task<UserLogin> GetLoginAsync(UserLoginFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| UserLoginFilter | filter | Filter criteria including provider and user information. Must not be null. |
| CancellationToken | cancellationToken | Cancellation token for the async operation. |
Returns
| Type | Description |
|---|---|
| Task<UserLogin> | The first UserLogin object matching the filter criteria, or null if none found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when filter is null. |
GetLoginsAsync(UserLoginFilter, CancellationToken)
Retrieves user login credentials based on the provided filter criteria.
Declaration
public Task<IEnumerable<UserLogin>> GetLoginsAsync(UserLoginFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| UserLoginFilter | filter | Filter criteria including UserIdMaster, ProviderKey, and LoginProvider. Must not be null. |
| CancellationToken | cancellationToken | Cancellation token for the async operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<UserLogin>> | An enumerable collection of UserLogin objects matching the filter criteria. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when filter is null. |
RemoveAllAsync(string, CancellationToken)
Removes all external login credentials for a user.
Declaration
public Task RemoveAllAsync(string userIdMaster, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userIdMaster | The user ID. Must not be null or empty. |
| CancellationToken | cancellationToken | Cancellation token for the async operation. |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
This operation removes all logins associated with the specified user. Use with caution.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when userIdMaster is null or empty. |
RemoveAsync(string, string, string, CancellationToken)
Removes a specific external login credential for a user.
Declaration
public Task RemoveAsync(string userIdMaster, string providerKey, string loginProvider, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userIdMaster | The user ID. Must not be null or empty. |
| string | providerKey | The external provider key. Must not be null or empty. |
| string | loginProvider | The name of the login provider. Must not be null or empty. |
| CancellationToken | cancellationToken | Cancellation token for the async operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when any parameter is null or empty. |