From 5a4ae121b93dd5a75d343cfce48c4649b40f6d9e Mon Sep 17 00:00:00 2001 From: ashish-egov Date: Fri, 21 Jun 2024 12:23:40 +0530 Subject: [PATCH] Enriching already exsisting user --- .../src/server/api/campaignApis.ts | 15 +++++++++++++-- .../src/server/service/dataManageService.ts | 1 + .../src/server/utils/genericUtils.ts | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/utilities/project-factory/src/server/api/campaignApis.ts b/utilities/project-factory/src/server/api/campaignApis.ts index e9d2cd8f158..780f6611e26 100644 --- a/utilities/project-factory/src/server/api/campaignApis.ts +++ b/utilities/project-factory/src/server/api/campaignApis.ts @@ -258,8 +258,18 @@ async function getUuidsError(request: any, response: any, mobileNumberRowNumberM errors.push({ status: "INVALID", rowNumber: mobileNumberRowNumberMapping[user?.mobileNumber], errorDetails: `User with mobileNumber ${user?.mobileNumber} doesn't have username` }) count++; } + else if (!user?.userDetails?.password) { + logger.info(`User with mobileNumber ${user?.mobileNumber} doesn't have password`) + errors.push({ status: "INVALID", rowNumber: mobileNumberRowNumberMapping[user?.mobileNumber], errorDetails: `User with mobileNumber ${user?.mobileNumber} doesn't have password` }) + count++; + } + else if (!user?.userUuid) { + logger.info(`User with mobileNumber ${user?.mobileNumber} doesn't have userServiceUuid`) + errors.push({ status: "INVALID", rowNumber: mobileNumberRowNumberMapping[user?.mobileNumber], errorDetails: `User with mobileNumber ${user?.mobileNumber} doesn't have userServiceUuid` }) + count++; + } else { - request.body.mobileNumberUuidsMapping[user?.mobileNumber] = { userUuid: user?.id, code: user?.userDetails?.username, rowNumber: mobileNumberRowNumberMapping[user?.mobileNumber] } + request.body.mobileNumberUuidsMapping[user?.mobileNumber] = { userUuid: user?.id, code: user?.userDetails?.username, rowNumber: mobileNumberRowNumberMapping[user?.mobileNumber], password: user?.userDetails?.password, userServiceUuid: user?.userUuid } } } if (count > 0) { @@ -692,7 +702,8 @@ async function enrichAlreadyExsistingUser(request: any) { employee.uuid = request?.body?.mobileNumberUuidsMapping[employee?.user?.mobileNumber].userUuid; employee.code = request?.body?.mobileNumberUuidsMapping[employee?.user?.mobileNumber].code; employee.user.userName = request?.body?.mobileNumberUuidsMapping[employee?.user?.mobileNumber].code; - employee.user.password = config.user.userDefaultPassword; + employee.user.password = request?.body?.mobileNumberUuidsMapping[employee?.user?.mobileNumber].password; + employee.user.userServiceUuid = request?.body?.mobileNumberUuidsMapping[employee?.user?.mobileNumber].userServiceUuid; } } } diff --git a/utilities/project-factory/src/server/service/dataManageService.ts b/utilities/project-factory/src/server/service/dataManageService.ts index ed224dc824f..12f60b61441 100644 --- a/utilities/project-factory/src/server/service/dataManageService.ts +++ b/utilities/project-factory/src/server/service/dataManageService.ts @@ -56,6 +56,7 @@ const getBoundaryDataService = async ( logger.info("RETURNS THE BOUNDARY RESPONSE"); return BoundaryFileDetails; } catch (e: any) { + console.log(e) logger.error(String(e)) // Handle errors and send error response throw (e); diff --git a/utilities/project-factory/src/server/utils/genericUtils.ts b/utilities/project-factory/src/server/utils/genericUtils.ts index f485d10f6ca..8bdc46dd7e0 100644 --- a/utilities/project-factory/src/server/utils/genericUtils.ts +++ b/utilities/project-factory/src/server/utils/genericUtils.ts @@ -280,6 +280,7 @@ async function searchGeneratedResources(request: any) { const queryResult = await executeQuery(queryString, queryValues); return generatedResourceTransformer(queryResult?.rows); } catch (error: any) { + console.log(error) logger.error(`Error fetching data from the database: ${error.message}`); throwError("COMMON", 500, "INTERNAL_SERVER_ERROR", error?.message); return null; // Return null in case of an error @@ -385,6 +386,7 @@ async function fullProcessFlowForNewEntry(newEntryResponse: any, generatedResour request.body.generatedResource = finalResponse; } } catch (error: any) { + console.log(error) handleGenerateError(newEntryResponse, generatedResource, error); } }