Table of Contents

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

context ApplicationDbContext

The 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

oauthAccount OAuthAccount

The OAuth account entity to create.

cancellationToken CancellationToken

Cancellation 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

provider OAuthProvider

The OAuth provider (Google, LinkedIn).

providerUserId string

The user ID from the OAuth provider.

cancellationToken CancellationToken

Cancellation 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

userId Guid

The unique identifier of the user.

cancellationToken CancellationToken

Cancellation 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

oauthAccount OAuthAccount

The OAuth account entity to update.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<OAuthAccount>

The updated OAuth account entity.