Table of Contents

Interface IAuthService

Namespace
Builvero.Application.Services
Assembly
Builvero.Application.dll

Defines the contract for user authentication operations including signup, login, OAuth, and JWT token generation.

public interface IAuthService

Remarks

This interface provides methods for:

  • User registration with invitation code validation
  • Email/password authentication
  • OAuth authentication (Google, LinkedIn) with account linking
  • JWT token generation for authenticated sessions
All authentication operations include profile photo URL mapping using environment-aware logic.

Methods

GenerateJwtTokenAsync(Guid, string, string, string, CancellationToken)

Generates a JWT (JSON Web Token) for user authentication.

Task<string> GenerateJwtTokenAsync(Guid userId, string email, string role, string status, CancellationToken cancellationToken = default)

Parameters

userId Guid

The unique identifier of the user.

email string

The email address of the user.

role string

The role of the user (e.g., "User", "Admin", "Moderator").

status string

The status of the user (e.g., "Active").

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<string>

A JWT token string that can be used for authenticated API requests.

HandleOAuthCallbackAsync(OAuthProvider, string, string, string?, string?, string?, CancellationToken)

Handles OAuth authentication callback from external providers (Google, LinkedIn, etc.).

Task<AuthResponse> HandleOAuthCallbackAsync(OAuthProvider provider, string providerUserId, string email, string? name, string? photoUrl, string? invitationCode, CancellationToken cancellationToken = default)

Parameters

provider OAuthProvider

The OAuth provider (e.g., Google, LinkedIn).

providerUserId string

The unique user identifier from the OAuth provider.

email string

The email address from the OAuth provider.

name string

The user's full name from the OAuth provider, if available.

photoUrl string

The user's profile photo URL from the OAuth provider, if available.

invitationCode string

Optional invitation code for new user registration.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<AuthResponse>

An AuthResponse containing the JWT token and user information.

Exceptions

Exception

Thrown when account is disabled, invitation code is required but missing/invalid, or email is already registered with a different auth method.

LoginAsync(LoginRequest, CancellationToken)

Authenticates a user with email and password credentials.

Task<AuthResponse> LoginAsync(LoginRequest request, CancellationToken cancellationToken = default)

Parameters

request LoginRequest

The login request containing email and password.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<AuthResponse>

An AuthResponse containing the JWT token and user information.

Exceptions

Exception

Thrown when credentials are invalid or account is disabled.

SignupAsync(SignupRequest, CancellationToken)

Registers a new user account with email and password.

Task<AuthResponse> SignupAsync(SignupRequest request, CancellationToken cancellationToken = default)

Parameters

request SignupRequest

The signup request containing email, password, password confirmation, and invitation code.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<AuthResponse>

An AuthResponse containing the JWT token and user information.

Exceptions

Exception

Thrown when invitation code is invalid, email is already registered, or password validation fails.

VerifyEmailAsync(VerifyEmailRequest, CancellationToken)

Verifies a user's email using a verification code and activates the account.

Task<AuthResponse> VerifyEmailAsync(VerifyEmailRequest request, CancellationToken cancellationToken = default)

Parameters

request VerifyEmailRequest

The verification request containing email and code.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<AuthResponse>

An AuthResponse containing a JWT token and user info once verified.