refactor(logging): replace console usage with logger
This commit is contained in:
@@ -3,6 +3,8 @@ import { MockDatabaseStrategy } from './MockDatabaseStrategy';
|
||||
import { ProductionDatabaseStrategy } from './ProductionDatabaseStrategy';
|
||||
import { DatabaseStrategy } from './types';
|
||||
import { AccountStatus } from '../auth/auth.constants';
|
||||
import { hashPassword } from '../auth/password.service';
|
||||
import { logger } from '../logging';
|
||||
|
||||
/**
|
||||
* Consolidated Database Service
|
||||
@@ -30,9 +32,9 @@ export class DatabaseService implements DatabaseStrategy {
|
||||
try {
|
||||
return new ProductionDatabaseStrategy();
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
'Production CouchDB service not available, falling back to mock:',
|
||||
error
|
||||
logger.db.warn(
|
||||
'Production CouchDB service not available, falling back to mock',
|
||||
error as Error
|
||||
);
|
||||
return new MockDatabaseStrategy();
|
||||
}
|
||||
@@ -188,9 +190,10 @@ export class DatabaseService implements DatabaseStrategy {
|
||||
async changeUserPassword(userId: string, newPassword: string) {
|
||||
const user = await this.strategy.getUserById(userId);
|
||||
if (!user) throw new Error('User not found');
|
||||
const hashedPassword = await hashPassword(newPassword);
|
||||
return this.strategy.updateUser({
|
||||
...user,
|
||||
password: newPassword,
|
||||
password: hashedPassword,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user