diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 43934c1a5..832595b30 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -113,16 +113,20 @@ 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 getClientData = await this.clientRegistrationService.getClientRedirectUrl(clientId, token); + const token = await this.clientRegistrationService.getManagementToken(decryptClientId, decryptClientSecret); + 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); } @@ -130,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; }