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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user