From 802a8c804a606bcb2bb986a8223905dbe4a17616 Mon Sep 17 00:00:00 2001 From: KulkarniShashank Date: Wed, 24 Jul 2024 17:35:55 +0530 Subject: [PATCH 1/2] fix: client id and client secret encrypt and decrypt Signed-off-by: KulkarniShashank --- apps/user/src/user.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 43934c1a5..bab73c9c0 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -113,8 +113,11 @@ export class UserService { const verifyCode = uuidv4(); let sendVerificationMail: boolean; + const decryptClientId = await this.commonService.decryptPassword(clientId); + const decryptClientSecret = await this.commonService.decryptPassword(clientSecret); + try { - const token = await this.clientRegistrationService.getManagementToken(clientId, clientSecret); + const token = await this.clientRegistrationService.getManagementToken(decryptClientId, decryptClientSecret); const getClientData = await this.clientRegistrationService.getClientRedirectUrl(clientId, token); const [redirectUrl] = getClientData[0]?.redirectUris || []; From 202f211d33666ae646f2b4e463d2ae618fe8cbdd Mon Sep 17 00:00:00 2001 From: KulkarniShashank Date: Thu, 25 Jul 2024 12:08:01 +0530 Subject: [PATCH 2/2] fix: dcrypted the clientId and client secret Signed-off-by: KulkarniShashank --- apps/user/src/user.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index bab73c9c0..832595b30 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -118,14 +118,15 @@ export class UserService { try { const token = await this.clientRegistrationService.getManagementToken(decryptClientId, decryptClientSecret); - const getClientData = await this.clientRegistrationService.getClientRedirectUrl(clientId, token); + const getClientData = await this.clientRegistrationService.getClientRedirectUrl(decryptClientId, token); + const [redirectUrl] = getClientData[0]?.redirectUris || []; if (!redirectUrl) { throw new NotFoundException(ResponseMessages.user.error.redirectUrlNotFound); } - sendVerificationMail = await this.sendEmailForVerification(email, verifyCode, redirectUrl, clientId, brandLogoUrl, platformName); + sendVerificationMail = await this.sendEmailForVerification(email, verifyCode, redirectUrl, decryptClientId, brandLogoUrl, platformName); } catch (error) { throw new InternalServerErrorException(ResponseMessages.user.error.emailSend); } @@ -133,6 +134,8 @@ export class UserService { if (sendVerificationMail) { const uniqueUsername = await this.createUsername(email, verifyCode); userEmailVerification.username = uniqueUsername; + userEmailVerification.clientId = decryptClientId; + userEmailVerification.clientSecret = decryptClientSecret; const resUser = await this.userRepository.createUser(userEmailVerification, verifyCode); return resUser; }