fix: refactor two commands in saving grade to prevent race conditions

This commit is contained in:
2024-01-20 13:13:59 +01:00
parent b897c775a9
commit 6b63fd498a
14 changed files with 140 additions and 97 deletions

View File

@@ -10,7 +10,10 @@ import { UsersRepository } from '../users/infrastructure/users.repository'
@Injectable()
export class AuthService {
constructor(private usersRepository: UsersRepository, private prisma: PrismaService) {}
constructor(
private usersRepository: UsersRepository,
private prisma: PrismaService
) {}
async createJwtTokensPair(userId: string, rememberMe?: boolean) {
const accessSecretKey = process.env.ACCESS_JWT_SECRET_KEY

View File

@@ -5,7 +5,10 @@ import * as jwt from 'jsonwebtoken'
import { AuthRepository } from '../infrastructure/auth.repository'
export class RefreshTokenCommand {
constructor(public readonly userId: string, public readonly shortAccessToken: boolean) {}
constructor(
public readonly userId: string,
public readonly shortAccessToken: boolean
) {}
}
@CommandHandler(RefreshTokenCommand)

View File

@@ -5,7 +5,10 @@ import { UsersRepository } from '../../users/infrastructure/users.repository'
import { UsersService } from '../../users/services/users.service'
export class ResetPasswordCommand {
constructor(public readonly resetPasswordToken: string, public readonly newPassword: string) {}
constructor(
public readonly resetPasswordToken: string,
public readonly newPassword: string
) {}
}
@CommandHandler(ResetPasswordCommand)