mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-25 05:09:25 +00:00
fix: refactor two commands in saving grade to prevent race conditions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user