fix(auth): resolve service import and dependency issues

- Replace dynamic imports with static imports for better test compatibility
- Fix circular dependency issues between auth service and CouchDB factory
- Use correct CouchDB service methods (createUserWithPassword, etc.)
- Remove unused imports and improve code organization
- Fix email verification service to work properly with mocked dependencies
- Ensure proper error handling and service interaction patterns
This commit is contained in:
William Valentin
2025-09-07 16:14:25 -07:00
parent 38699c6724
commit 2e3fbaf1e6
2 changed files with 16 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ import { v4 as uuidv4 } from 'uuid';
import { EmailVerificationToken, AuthenticatedUser } from './auth.types';
import { mailgunService } from '../mailgun.service';
import { AccountStatus } from './auth.constants';
import { dbService } from '../couchdb.factory';
const TOKEN_EXPIRY_HOURS = 24;
@@ -62,7 +63,6 @@ export class EmailVerificationService {
}
// Find the user (in production, this would be a proper database lookup)
const { dbService } = await import('../couchdb');
const user = await dbService.findUserByEmail(verificationToken.email);
return user as AuthenticatedUser;
@@ -70,7 +70,6 @@ export class EmailVerificationService {
async markEmailVerified(user: AuthenticatedUser): Promise<void> {
// Update user in database
const { dbService } = await import('../couchdb');
const updatedUser = {
...user,
emailVerified: true,