Skip to main content

auth.FirebaseAuthService

Defined in: backend/src/modules/auth/services/FirebaseAuthService.ts:50

Service that implements authentication functionality using Firebase Auth. Handles user registration, token verification, and password management.

Implements

Implements

Constructors

Constructor

new FirebaseAuthService(userRepository): FirebaseAuthService

Defined in: backend/src/modules/auth/services/FirebaseAuthService.ts:67

Creates a new Firebase authentication service instance. Initializes Firebase Admin SDK with application default credentials.

Parameters

userRepository

IUserRepository

Repository for storing and retrieving user data

Returns

FirebaseAuthService

Methods

changePassword()

changePassword(body, requestUser): Promise<{ message: string; success: boolean; }>

Defined in: backend/src/modules/auth/services/FirebaseAuthService.ts:215

Changes a user's password in Firebase Auth. Verifies that passwords match and the user exists before making changes.

Parameters

body

ChangePasswordBody

Contains the new password and confirmation

requestUser

IUser

The authenticated user requesting the password change

Returns

Promise<{ message: string; success: boolean; }>

A promise resolving to a success confirmation object

Throws

ChangePasswordError - If passwords don't match or user doesn't exist

Implementation of

IAuthService.changePassword


signup()

signup(body): Promise<IUser>

Defined in: backend/src/modules/auth/services/FirebaseAuthService.ts:112

Registers a new user with Firebase Auth and stores user data in the repository.

Parameters

body

SignUpBody

The validated signup information including email, password, and name

Returns

Promise<IUser>

A promise resolving to the newly created user object

Throws

Error - If user creation fails in either Firebase or the repository

Implementation of

IAuthService.signup


verifySignUpProvider()

verifySignUpProvider(token): Promise<IUser>

Defined in: backend/src/modules/auth/services/FirebaseAuthService.ts:163

Verifies a Firebase authentication token and returns the associated user.

Parameters

token

string

The Firebase ID token to verify

Returns

Promise<IUser>

A promise that resolves to the user data associated with the token

Throws

Error - If the token is invalid or verification fails

Implementation of

IAuthService.verifySignUpProvider


verifyToken()

verifyToken(token): Promise<IUser>

Defined in: backend/src/modules/auth/services/FirebaseAuthService.ts:83

Verifies a Firebase authentication token and returns the associated user.

Parameters

token

string

The Firebase ID token to verify

Returns

Promise<IUser>

A promise that resolves to the user data associated with the token

Throws

Error - If the token is invalid or verification fails

Implementation of

IAuthService.verifyToken