Class OAuthAccountRepository
- Namespace
- Builvero.Infrastructure.Repositories
- Assembly
- Builvero.Infrastructure.dll
Repository implementation for OAuth account data access operations using Entity Framework Core.
public class OAuthAccountRepository : IOAuthAccountRepository
- Inheritance
-
OAuthAccountRepository
- Implements
- Inherited Members
Remarks
OAuth accounts link external authentication providers (Google, LinkedIn) to user accounts.
Constructors
OAuthAccountRepository(ApplicationDbContext)
Initializes a new instance of the OAuthAccountRepository class.
public OAuthAccountRepository(ApplicationDbContext context)
Parameters
contextApplicationDbContextThe Entity Framework database context for data access.
Methods
CreateAsync(OAuthAccount, CancellationToken)
Creates a new OAuth account in the database.
public Task<OAuthAccount> CreateAsync(OAuthAccount oauthAccount, CancellationToken cancellationToken = default)
Parameters
oauthAccountOAuthAccountThe OAuth account entity to create.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<OAuthAccount>
The created OAuth account entity with its generated ID.
GetByProviderAndProviderUserIdAsync(OAuthProvider, string, CancellationToken)
Retrieves an OAuth account by provider and provider user ID.
public Task<OAuthAccount?> GetByProviderAndProviderUserIdAsync(OAuthProvider provider, string providerUserId, CancellationToken cancellationToken = default)
Parameters
providerOAuthProviderThe OAuth provider (Google, LinkedIn).
providerUserIdstringThe user ID from the OAuth provider.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<OAuthAccount>
The OAuth account with User and Profile loaded, or null if not found.
GetByUserIdAsync(Guid, CancellationToken)
Retrieves all OAuth accounts associated with a user.
public Task<List<OAuthAccount>> GetByUserIdAsync(Guid userId, CancellationToken cancellationToken = default)
Parameters
userIdGuidThe unique identifier of the user.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<List<OAuthAccount>>
A list of OAuth accounts for the specified user.
UpdateAsync(OAuthAccount, CancellationToken)
Updates an existing OAuth account in the database.
public Task<OAuthAccount> UpdateAsync(OAuthAccount oauthAccount, CancellationToken cancellationToken = default)
Parameters
oauthAccountOAuthAccountThe OAuth account entity to update.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<OAuthAccount>
The updated OAuth account entity.