database migrated to POSTGRESQL

This commit is contained in:
2026-10-13 16:11:51 +03:30
parent 41ad8c1063
commit 514c3ccaf0
47 changed files with 1500 additions and 891 deletions
+10 -10
View File
@@ -35,27 +35,27 @@ export class AuthService {
}
if (!user.isActive) {
await this.auditFailedLogin(user._id.toString(), user.username, 'inactive', context);
await this.auditFailedLogin(user.id, user.username, 'inactive', context);
throw new AppException('ACCOUNT_INACTIVE');
}
if (user.isBlocked) {
await this.auditFailedLogin(user._id.toString(), user.username, 'blocked', context);
await this.auditFailedLogin(user.id, user.username, 'blocked', context);
throw new AppException('ACCOUNT_BLOCKED');
}
const valid = await this.passwordService.compare(dto.password, user.password);
if (!valid) {
await this.auditFailedLogin(user._id.toString(), user.username, 'invalid_credentials', context);
await this.auditFailedLogin(user.id, user.username, 'invalid_credentials', context);
throw new AppException('INVALID_CREDENTIALS');
}
const tokens = await this.issueTokens(user);
await this.usersService.saveRefreshToken(user._id.toString(), tokens.refreshToken);
await this.usersService.recordLogin(user._id.toString());
await this.usersService.saveRefreshToken(user.id, tokens.refreshToken);
await this.usersService.recordLogin(user.id);
await this.auditService.log(AuditEvent.LOGIN, {
userId: user._id.toString(),
userId: user.id,
username: user.username,
ip: context.ip,
userAgent: context.userAgent,
@@ -86,10 +86,10 @@ export class AuthService {
}
const tokens = await this.issueTokens(user);
await this.usersService.saveRefreshToken(user._id.toString(), tokens.refreshToken);
await this.usersService.saveRefreshToken(user.id, tokens.refreshToken);
await this.auditService.log(AuditEvent.LOGIN, {
userId: user._id.toString(),
userId: user.id,
username: user.username,
ip: context.ip,
userAgent: context.userAgent,
@@ -117,13 +117,13 @@ export class AuthService {
}
private async issueTokens(user: {
_id: { toString(): string };
id: string;
role: JwtPayload['role'];
clientType: JwtPayload['clientType'];
appName: string;
}): Promise<AuthTokensDto> {
const payload: JwtPayload = {
sub: user._id.toString(),
sub: user.id,
role: user.role,
clientType: user.clientType,
appName: user.appName,
+1 -1
View File
@@ -35,7 +35,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, JWT_ACCESS_STRATEGY)
}
return {
id: user._id.toString(),
id: user.id,
username: user.username,
email: user.email,
role: user.role,