From fd3da43b24574af0847e6da54f77356f43cc6e1d Mon Sep 17 00:00:00 2001 From: ashish-egov <137176738+ashish-egov@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:54:48 +0530 Subject: [PATCH] Update campaignApis.ts (#1310) * Update campaignApis.ts * Update campaignApis.ts --- .../src/server/api/campaignApis.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/utilities/project-factory/src/server/api/campaignApis.ts b/utilities/project-factory/src/server/api/campaignApis.ts index c7f4683b859..838950ae0ea 100644 --- a/utilities/project-factory/src/server/api/campaignApis.ts +++ b/utilities/project-factory/src/server/api/campaignApis.ts @@ -564,15 +564,6 @@ function convertUserRoles(employees: any[], request: any) { } } -function generateHash(input: string): string { - const prime = 31; // Prime number - let hash = 0; - for (let i = 0; i < input.length; i++) { - hash = (hash * prime + input.charCodeAt(i)) % 100000; // Limit hash to 5 digits - } - return hash.toString().padStart(6, '0'); -} - function generateUserPassword() { // Function to generate a random lowercase letter function getRandomLowercaseLetter() { @@ -609,15 +600,12 @@ function generateUserPassword() { function enrichUserNameAndPassword(employees: any[]) { - const epochTime = Date.now(); employees.forEach((employee) => { - const { user, "!row#number!": rowNumber } = employee; - const nameInitials = user.name.split(' ').map((name: any) => name.charAt(0)).join(''); - const generatedCode = `${nameInitials}${generateHash(`${epochTime}`)}${rowNumber}`; + const { user } = employee; const generatedPassword = config?.user?.userPasswordAutoGenerate == "true" ? generateUserPassword() : config?.user?.userDefaultPassword - user.userName = generatedCode; + user.userName = null; user.password = generatedPassword; - employee.code = generatedCode + employee.code = null }); }