Skip to content

Commit 4179aee

Browse files
authored
feat(mon-domifa): create all accounts 'Mon-DomiFa' in one shot (#3854)
* fix(chore): reorganize services in manage * feat(mon-domifa): create all accounts in one shot * fix(frontend): fix unit tests * feat(mon-domifa): add passwordType * fix(backend): fix migration * fix(backend): fix migration * fix(frontend): fix update angular v19
1 parent 49e694b commit 4179aee

File tree

47 files changed

+1330
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1330
-206
lines changed

.talismanrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ fileignoreconfig:
44
- filename: _docs/dev/0.run-local-env.md
55
checksum: 855b6f29ace746c86597d36382dbe7e40f771137734e3bf5eb53c948d6592a74
66
- filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql
7-
checksum: 6786973ce45c4e9f98501703bb28b21f487818ddbffcd30b35cb0499a659c9ef
7+
checksum: 90f61b5faa4fd3da9b0722538c036ff58ca8f2d388091f22e8b348a3b09ef37b
88
- filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql
9-
checksum: c68a6bc52521795e41b2d5ecddb9fb907ada5fce5bb1fef7fef4709fac8e0677
9+
checksum: c510b7ad49f07d80c5a4951ca86c62d55dab6a3fb5b2dcc6947f8022cb08eea7
1010
- filename: packages/backend/package.json
1111
checksum: 2f5813dbc35cdc3659516beabf9f93e2978eb62d1b5403cfbb2907f22bb25355
1212
- filename: packages/portail-admins/src/app/modules/admin-structures/components/admin-structures-list/admin-structures-list.component.spec.ts
68 Bytes
Binary file not shown.

_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ f1d8975b-e429-41db-9246-bb2b388aece6 2025-04-15 20:14:04.704668+02 2025-04-15 20
336336
-- Data for Name: user_usager; Type: TABLE DATA; Schema: public; Owner: -
337337
--
338338
339-
COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", enabled, "acceptTerms") FROM stdin;
340-
a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$/MxpSdJoHG59JaksJx5eSe4U1tHGcVoHEvlDRoi.AsVW2LlybKNnG $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} t \N
341-
a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2023-12-18 17:54:10.81286+01 19 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$1rKKqmxsaIKyNkyZpm5QHufHZ8JfCSgEtaLOv07oy2QE.O8msCVPO $2a$10$1rKKqmxsaIKyNkyZpm5QHu t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} t \N
339+
COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", "acceptTerms", "passwordType") FROM stdin;
340+
a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2023-12-18 17:54:10.81286+01 19 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$1rKKqmxsaIKyNkyZpm5QHufHZ8JfCSgEtaLOv07oy2QE.O8msCVPO $2a$10$1rKKqmxsaIKyNkyZpm5QHu t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} \N BIRTH_DATE
341+
a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$/MxpSdJoHG59JaksJx5eSe4U1tHGcVoHEvlDRoi.AsVW2LlybKNnG $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} \N PERSONAL
342342
\.
343343
344344

_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ f1d8975b-e429-41db-9246-bb2b388aece6 2025-04-15 20:14:04.704668+02 2025-04-15 20
372372
-- Data for Name: user_usager; Type: TABLE DATA; Schema: public; Owner: -
373373
--
374374
375-
COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", enabled, "acceptTerms") FROM stdin;
376-
a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$/MxpSdJoHG59JaksJx5eSe4U1tHGcVoHEvlDRoi.AsVW2LlybKNnG $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} t \N
377-
a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2023-12-18 17:54:10.81286+01 19 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$1rKKqmxsaIKyNkyZpm5QHufHZ8JfCSgEtaLOv07oy2QE.O8msCVPO $2a$10$1rKKqmxsaIKyNkyZpm5QHu t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} t \N
375+
COPY public.user_usager (uuid, "createdAt", "updatedAt", version, id, "usagerUUID", "structureId", login, password, salt, "isTemporaryPassword", "lastLogin", "passwordLastUpdate", "lastPasswordResetDate", "lastPasswordResetStructureUser", "acceptTerms", "passwordType") FROM stdin;
376+
a657f4bd-e4d1-4c38-bdd0-ffd268b356df 2021-10-05 11:34:41.369505+02 2023-12-18 17:54:10.81286+01 19 1 b2c26e55-ab37-457d-b307-6fe161050a9b 1 WKYJBDXS $2a$10$1rKKqmxsaIKyNkyZpm5QHufHZ8JfCSgEtaLOv07oy2QE.O8msCVPO $2a$10$1rKKqmxsaIKyNkyZpm5QHu t 2021-11-30 15:02:07.69+01 \N 2021-10-05 11:34:41.365+02 {"userId": 1, "userName": "Patrick Roméro"} \N BIRTH_DATE
377+
a03a9a49-ae31-4160-9879-bab02dc46361 2021-11-30 14:50:26.278073+01 2023-11-20 16:40:58.362384+01 17 2 97b7e840-0e93-4bf4-ba7d-0a406aa898f2 1 LNQIFFBK $2a$10$/MxpSdJoHG59JaksJx5eSe4U1tHGcVoHEvlDRoi.AsVW2LlybKNnG $2a$10$zmuPXxUOuQJ7nE6ag4.x6e f 2023-11-20 16:40:58.36+01 2021-11-30 15:01:39.675+01 2021-11-30 14:50:26.275+01 {"userId": 1, "userName": "Patrick Roméro"} \N PERSONAL
378378
\.
379379
380380

packages/backend/src/_common/model/app-log/LogAction.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type LogAction =
1515
// Mon DomiFa
1616
| "MON_DOMIFA_DOWNLOAD_DOC"
1717
| "MON_DOMIFA_DOWNLOAD_DOC_TRY"
18+
| "MON_DOMIFA_CREATE_PORTAIL_ACCOUNT_BULK"
1819
///
1920
| "EXPORT_USAGERS"
2021
| "GET_STATS"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
import { domifaConfig } from "../config";
3+
4+
export class AutoMigration1755523274894 implements MigrationInterface {
5+
name = "AutoMigration1755523274894";
6+
7+
public async up(queryRunner: QueryRunner): Promise<void> {
8+
if (
9+
domifaConfig().envId === "prod" ||
10+
domifaConfig().envId === "preprod" ||
11+
domifaConfig().envId === "local"
12+
) {
13+
await queryRunner.query(
14+
`ALTER TABLE "user_usager" ADD "passwordType" text NOT NULL DEFAULT true`
15+
);
16+
17+
await queryRunner.query(
18+
` ALTER TABLE "user_usager" DROP COLUMN "enabled" `
19+
);
20+
}
21+
}
22+
23+
public async down(queryRunner: QueryRunner): Promise<void> {
24+
await queryRunner.query(
25+
`ALTER TABLE "user_usager" DROP COLUMN "passwordType"`
26+
);
27+
}
28+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class AutoMigration1755523274895 implements MigrationInterface {
4+
name = "AutoMigration1755523274895";
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
console.log("🚀 Starting password type migration");
8+
9+
const cutoffDate = "2024-08-15";
10+
11+
// Initial stats
12+
const initialStats = await queryRunner.query(
13+
`
14+
SELECT
15+
COUNT(*) as totalAccounts,
16+
COUNT(*) FILTER (WHERE "createdAt" >= $1) as createdAfterCutoff,
17+
COUNT(*) FILTER (WHERE "createdAt" < $1) as createdBeforeCutoff,
18+
COUNT(*) FILTER (WHERE "isTemporaryPassword" = true) as temporaryPasswords,
19+
COUNT(*) FILTER (WHERE "isTemporaryPassword" = false) as personalPasswords
20+
FROM user_usager
21+
`,
22+
[cutoffDate]
23+
);
24+
25+
console.log(`📊 Initial stats:`, initialStats[0]);
26+
27+
// Update RANDOM (isTemporaryPassword = true AND created after cutoff)
28+
const randomUpdates = await queryRunner.query(
29+
`
30+
UPDATE user_usager
31+
SET "passwordType" = 'RANDOM'
32+
WHERE "isTemporaryPassword" = true
33+
AND "createdAt" >= $1
34+
`,
35+
[cutoffDate]
36+
);
37+
38+
console.log(
39+
`✅ Set ${randomUpdates.affectedRows || 0} accounts to RANDOM type`
40+
);
41+
42+
// Update BIRTH_DATE (isTemporaryPassword = true AND created before cutoff)
43+
const birthDateUpdates = await queryRunner.query(
44+
`
45+
UPDATE user_usager
46+
SET "passwordType" = 'BIRTH_DATE'
47+
WHERE "isTemporaryPassword" = true
48+
AND "createdAt" < $1
49+
`,
50+
[cutoffDate]
51+
);
52+
53+
console.log(
54+
`✅ Set ${birthDateUpdates.affectedRows || 0} accounts to BIRTH_DATE type`
55+
);
56+
57+
// Update PERSONAL (isTemporaryPassword = false)
58+
const personalUpdates = await queryRunner.query(`
59+
UPDATE user_usager
60+
SET "passwordType" = 'PERSONAL'
61+
WHERE "isTemporaryPassword" = false
62+
`);
63+
64+
console.log(
65+
`✅ Set ${personalUpdates.affectedRows || 0} accounts to PERSONAL type`
66+
);
67+
68+
// Final verification
69+
const finalStats = await queryRunner.query(`
70+
SELECT
71+
"passwordType",
72+
COUNT(*) as count
73+
FROM user_usager
74+
GROUP BY "passwordType"
75+
ORDER BY "passwordType"
76+
`);
77+
78+
console.log("📊 Final distribution:");
79+
finalStats.forEach((stat) => {
80+
console.log(` ${stat.passwordType || "NULL"}: ${stat.count} accounts`);
81+
});
82+
83+
console.log("🎉 Password type migration completed!");
84+
}
85+
86+
public async down(queryRunner: QueryRunner): Promise<void> {
87+
await queryRunner.query(
88+
`ALTER TABLE "user_usager" DROP COLUMN "passwordType"`
89+
);
90+
}
91+
}

0 commit comments

Comments
 (0)