Class UserLoginStore
SQL Server implementation of the user login store, managing external login credentials for users.
Implements
Inherited Members
Namespace: DataWeb.Identity.SqlServer
Assembly: DataWeb.Data.SqlServer.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 table with parametrized queries for SQL injection protection.
Constructors
UserLoginStore(ISqlHelper)
SQL Server implementation of the user login store, managing external login credentials for users.
Declaration
public UserLoginStore(ISqlHelper sqlHelper)
Parameters
| Type | Name | Description |
|---|---|---|
| ISqlHelper | sqlHelper |
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 table with parametrized queries for SQL 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. |