diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 4f979b42..c8734819 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3534,13 +3534,17 @@ export class CommandController extends Controller { if (checkUser.length == 0) { let password = profile.citizenId; if (profile.birthDate != null) { - const gregorianYear = profile.birthDate.getFullYear() + 543; + // const gregorianYear = profile.birthDate.getFullYear() + 543; - const formattedDate = - profile.birthDate.toISOString().slice(8, 10) + - profile.birthDate.toISOString().slice(5, 7) + - gregorianYear; - password = formattedDate; + // const formattedDate = + // profile.birthDate.toISOString().slice(8, 10) + + // profile.birthDate.toISOString().slice(5, 7) + + // gregorianYear; + // password = formattedDate; + const _date = new Date(profile.birthDate.toDateString()).getDate().toString().padStart(2, "0"); + const _month = (new Date(profile.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0"); + const _year = (new Date(profile.birthDate.toDateString()).getFullYear()+543); + password = `${_date}${_month}${_year}` } userKeycloakId = await createUser(profile.citizenId, password, { firstName: profile.firstName, @@ -5411,13 +5415,17 @@ export class CommandController extends Controller { if (checkUser.length == 0) { let password = item.bodyProfile.citizenId; if (item.bodyProfile.birthDate != null) { - const gregorianYear = item.bodyProfile.birthDate.getFullYear() + 543; + // const gregorianYear = item.bodyProfile.birthDate.getFullYear() + 543; - const formattedDate = - item.bodyProfile.birthDate.toISOString().slice(8, 10) + - item.bodyProfile.birthDate.toISOString().slice(5, 7) + - gregorianYear; - password = formattedDate; + // const formattedDate = + // item.bodyProfile.birthDate.toISOString().slice(8, 10) + + // item.bodyProfile.birthDate.toISOString().slice(5, 7) + + // gregorianYear; + // password = formattedDate; + const _date = new Date(item.bodyProfile.birthDate.toDateString()).getDate().toString().padStart(2, "0"); + const _month = (new Date(item.bodyProfile.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0"); + const _year = (new Date(item.bodyProfile.birthDate.toDateString()).getFullYear()+543); + password = `${_date}${_month}${_year}` } userKeycloakId = await createUser(item.bodyProfile.citizenId, password, { firstName: item.bodyProfile.firstName, @@ -6102,13 +6110,17 @@ export class CommandController extends Controller { if (checkUser.length == 0) { let password = profile.citizenId; if (profile.birthDate != null) { - const gregorianYear = profile.birthDate.getFullYear() + 543; + // const gregorianYear = profile.birthDate.getFullYear() + 543; - const formattedDate = - profile.birthDate.toISOString().slice(8, 10) + - profile.birthDate.toISOString().slice(5, 7) + - gregorianYear; - password = formattedDate; + // const formattedDate = + // profile.birthDate.toISOString().slice(8, 10) + + // profile.birthDate.toISOString().slice(5, 7) + + // gregorianYear; + // password = formattedDate; + const _date = new Date(profile.birthDate.toDateString()).getDate().toString().padStart(2, "0"); + const _month = (new Date(profile.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0"); + const _year = (new Date(profile.birthDate.toDateString()).getFullYear()+543); + password = `${_date}${_month}${_year}` } const userKeycloakId = await createUser(profile.citizenId, password, { firstName: profile.firstName, diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index b35966dd..e808a2be 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -845,13 +845,17 @@ export class KeycloakController extends Controller { for await (const _item of profiles) { let password = _item.citizenId; if (_item.birthDate != null) { - const gregorianYear = _item.birthDate.getFullYear() + 543; + // const gregorianYear = _item.birthDate.getFullYear() + 543; - const formattedDate = - _item.birthDate.toISOString().slice(8, 10) + - _item.birthDate.toISOString().slice(5, 7) + - gregorianYear; - password = formattedDate; + // const formattedDate = + // _item.birthDate.toISOString().slice(8, 10) + + // _item.birthDate.toISOString().slice(5, 7) + + // gregorianYear; + // password = formattedDate; + const _date = new Date(_item.birthDate.toDateString()).getDate().toString().padStart(2, "0"); + const _month = (new Date(_item.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0"); + const _year = (new Date(_item.birthDate.toDateString()).getFullYear()+543); + password = `${_date}${_month}${_year}` } const checkUser = await getUserByUsername(_item.citizenId); let userId: any = ""; @@ -907,13 +911,17 @@ export class KeycloakController extends Controller { for await (const _item of profiles) { let password = _item.citizenId; if (_item.birthDate != null) { - const gregorianYear = _item.birthDate.getFullYear() + 543; + // const gregorianYear = _item.birthDate.getFullYear() + 543; - const formattedDate = - _item.birthDate.toISOString().slice(8, 10) + - _item.birthDate.toISOString().slice(5, 7) + - gregorianYear; - password = formattedDate; + // const formattedDate = + // _item.birthDate.toISOString().slice(8, 10) + + // _item.birthDate.toISOString().slice(5, 7) + + // gregorianYear; + // password = formattedDate; + const _date = new Date(_item.birthDate.toDateString()).getDate().toString().padStart(2, "0"); + const _month = (new Date(_item.birthDate.toDateString()).getMonth()+1).toString().padStart(2, "0"); + const _year = (new Date(_item.birthDate.toDateString()).getFullYear()+543); + password = `${_date}${_month}${_year}` } const checkUser = await getUserByUsername(_item.citizenId); let userId: any = "";