From f16162a6b3c076f1f84c4432cf1b0ed238138550 Mon Sep 17 00:00:00 2001 From: RITIKA MANDAL Date: Tue, 21 May 2024 10:27:59 +0530 Subject: [PATCH] refactor(api): Replaced OTP code from alphanumeric to numeric (#230) --- apps/api/src/auth/service/auth.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/api/src/auth/service/auth.service.ts b/apps/api/src/auth/service/auth.service.ts index 58f94502..e4ce6846 100644 --- a/apps/api/src/auth/service/auth.service.ts +++ b/apps/api/src/auth/service/auth.service.ts @@ -7,7 +7,6 @@ import { NotFoundException, UnauthorizedException } from '@nestjs/common' -import { randomUUID } from 'crypto' import { JwtService } from '@nestjs/jwt' import { Cron, CronExpression } from '@nestjs/schedule' import { UserAuthenticatedResponse } from '../auth.types' @@ -45,11 +44,11 @@ export class AuthService { userId: user.id }, update: { - code: randomUUID().slice(0, 6).toUpperCase(), + code: BigInt(`0x${crypto.randomUUID().replace(/-/g, '')}`).toString().substring(0, 6), expiresAt: new Date(new Date().getTime() + this.OTP_EXPIRY) }, create: { - code: randomUUID().slice(0, 6).toUpperCase(), + code: BigInt(`0x${crypto.randomUUID().replace(/-/g, '')}`).toString().substring(0, 6), expiresAt: new Date(new Date().getTime() + this.OTP_EXPIRY), user: { connect: {