@proconnect-gouv/proconnect.identite 15.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/connectors/index.d.ts +2 -72
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +5 -14
- package/dist/managers/certification/certification-score.d.ts +16 -0
- package/dist/managers/certification/certification-score.d.ts.map +1 -1
- package/dist/managers/certification/certification-score.js +65 -41
- package/dist/managers/certification/process-certification-dirigeant.d.ts.map +1 -1
- package/dist/managers/organization/get-organization-info.d.ts.map +1 -1
- package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.d.ts +3 -0
- package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.d.ts.map +1 -0
- package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.js +12 -0
- package/dist/repositories/authenticator/index.d.ts +1 -1
- package/dist/repositories/authenticator/index.d.ts.map +1 -1
- package/dist/repositories/authenticator/index.js +1 -1
- package/dist/repositories/moderation/index.d.ts +0 -2
- package/dist/repositories/moderation/index.d.ts.map +1 -1
- package/dist/repositories/moderation/index.js +0 -2
- package/dist/repositories/oidc-client/upsert-authorization-request.d.ts +1 -1
- package/dist/repositories/oidc-client/upsert-authorization-request.d.ts.map +1 -1
- package/dist/repositories/oidc-client/upsert-authorization-request.js +6 -4
- package/dist/repositories/organization/index.d.ts +0 -2
- package/dist/repositories/organization/index.d.ts.map +1 -1
- package/dist/repositories/organization/index.js +0 -2
- package/dist/repositories/user/index.d.ts +0 -1
- package/dist/repositories/user/index.d.ts.map +1 -1
- package/dist/repositories/user/index.js +0 -1
- package/dist/services/organization/get-membership-changes-by-domain-verification.d.ts +18 -0
- package/dist/services/organization/get-membership-changes-by-domain-verification.d.ts.map +1 -0
- package/dist/services/organization/get-membership-changes-by-domain-verification.js +21 -0
- package/dist/services/organization/index.d.ts +1 -1
- package/dist/services/organization/index.d.ts.map +1 -1
- package/dist/services/organization/index.js +1 -1
- package/dist/types/authenticator.d.ts.map +1 -1
- package/dist/types/authorization-request.d.ts +2 -0
- package/dist/types/authorization-request.d.ts.map +1 -1
- package/dist/types/authorization-request.js +4 -1
- package/package.json +2 -2
- package/src/connectors/index.ts +2 -17
- package/src/managers/certification/certification-score.test.ts +64 -1
- package/src/managers/certification/certification-score.ts +84 -50
- package/src/managers/certification/process-certification-dirigeant.ts +1 -2
- package/src/managers/organization/get-organization-info.ts +1 -2
- package/src/repositories/authenticator/delete-all-authenticators-by-user-id.test.ts +51 -0
- package/src/repositories/authenticator/delete-all-authenticators-by-user-id.ts +22 -0
- package/src/repositories/authenticator/index.ts +1 -1
- package/src/repositories/moderation/index.ts +0 -2
- package/src/repositories/oidc-client/upsert-authorization-request.test.ts +18 -5
- package/src/repositories/oidc-client/upsert-authorization-request.ts +6 -3
- package/src/repositories/organization/index.ts +0 -2
- package/src/repositories/user/index.ts +0 -1
- package/src/services/organization/get-membership-changes-by-domain-verification.test.ts +91 -0
- package/src/services/organization/get-membership-changes-by-domain-verification.ts +46 -0
- package/src/services/organization/index.ts +1 -1
- package/src/types/authenticator.ts +1 -7
- package/src/types/authorization-request.ts +5 -1
- package/testing/index.ts +2 -1
- package/dist/repositories/authenticator/update-authenticator.d.ts +0 -3
- package/dist/repositories/authenticator/update-authenticator.d.ts.map +0 -1
- package/dist/repositories/authenticator/update-authenticator.js +0 -13
- package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.d.ts +0 -3
- package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.d.ts.map +0 -1
- package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.js +0 -15
- package/dist/repositories/email-deliverability-whitelist/index.d.ts +0 -2
- package/dist/repositories/email-deliverability-whitelist/index.d.ts.map +0 -1
- package/dist/repositories/email-deliverability-whitelist/index.js +0 -2
- package/dist/repositories/moderation/find-pending-moderation.d.ts +0 -20
- package/dist/repositories/moderation/find-pending-moderation.d.ts.map +0 -1
- package/dist/repositories/moderation/find-pending-moderation.js +0 -16
- package/dist/repositories/moderation/find-rejected-moderation.d.ts +0 -20
- package/dist/repositories/moderation/find-rejected-moderation.d.ts.map +0 -1
- package/dist/repositories/moderation/find-rejected-moderation.js +0 -17
- package/dist/repositories/organization/find-by-siret.d.ts +0 -3
- package/dist/repositories/organization/find-by-siret.d.ts.map +0 -1
- package/dist/repositories/organization/find-by-siret.js +0 -13
- package/dist/repositories/organization/find-pending-by-user-id.d.ts +0 -6
- package/dist/repositories/organization/find-pending-by-user-id.d.ts.map +0 -1
- package/dist/repositories/organization/find-pending-by-user-id.js +0 -18
- package/dist/repositories/user/find-by-reset-password-token.d.ts +0 -29
- package/dist/repositories/user/find-by-reset-password-token.d.ts.map +0 -1
- package/dist/repositories/user/find-by-reset-password-token.js +0 -12
- package/dist/services/organization/get-member-ids-promoted-by-domain.d.ts +0 -9
- package/dist/services/organization/get-member-ids-promoted-by-domain.d.ts.map +0 -1
- package/dist/services/organization/get-member-ids-promoted-by-domain.js +0 -11
- package/src/repositories/authenticator/update-authenticator.test.ts +0 -41
- package/src/repositories/authenticator/update-authenticator.ts +0 -29
- package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.test.ts +0 -45
- package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.ts +0 -24
- package/src/repositories/email-deliverability-whitelist/index.ts +0 -3
- package/src/repositories/moderation/find-pending-moderation.test.ts +0 -57
- package/src/repositories/moderation/find-pending-moderation.ts +0 -35
- package/src/repositories/moderation/find-rejected-moderation.test.ts +0 -57
- package/src/repositories/moderation/find-rejected-moderation.ts +0 -37
- package/src/repositories/organization/find-by-siret.test.ts +0 -35
- package/src/repositories/organization/find-by-siret.ts +0 -21
- package/src/repositories/organization/find-pending-by-user-id.test.ts +0 -51
- package/src/repositories/organization/find-pending-by-user-id.ts +0 -27
- package/src/repositories/user/find-by-reset-password-token.test.ts +0 -37
- package/src/repositories/user/find-by-reset-password-token.ts +0 -20
- package/src/services/organization/get-member-ids-promoted-by-domain.test.ts +0 -100
- package/src/services/organization/get-member-ids-promoted-by-domain.ts +0 -27
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { findPendingModerationFactory } from "./find-pending-moderation.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const findPendingModeration = findPendingModerationFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("findPendingModerationFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should return undefined when no pending moderation exists", async () => {
|
|
17
|
-
const moderation = await findPendingModeration({
|
|
18
|
-
user_id: 1,
|
|
19
|
-
organization_id: 1,
|
|
20
|
-
type: "organization_join_block",
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
assert.equal(moderation, undefined);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("should return the pending moderation", async () => {
|
|
27
|
-
await pg.sql`
|
|
28
|
-
INSERT INTO organizations
|
|
29
|
-
(cached_libelle, cached_nom_complet, id, siret, created_at, updated_at)
|
|
30
|
-
VALUES
|
|
31
|
-
('Necron', 'Necrontyr', 1, '⚰️', '1967-12-19', '1967-12-19')
|
|
32
|
-
;
|
|
33
|
-
`;
|
|
34
|
-
await pg.sql`
|
|
35
|
-
INSERT INTO users
|
|
36
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
37
|
-
VALUES
|
|
38
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
39
|
-
;
|
|
40
|
-
`;
|
|
41
|
-
await pg.sql`
|
|
42
|
-
INSERT INTO moderations
|
|
43
|
-
(id, user_id, organization_id, type, status, created_at)
|
|
44
|
-
VALUES
|
|
45
|
-
(1, 1, 1, 'organization_join_block', 'pending', '4444-04-04')
|
|
46
|
-
;
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
const moderation = await findPendingModeration({
|
|
50
|
-
user_id: 1,
|
|
51
|
-
organization_id: 1,
|
|
52
|
-
type: "organization_join_block",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
assert.equal(moderation?.id, 1);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type DatabaseContext,
|
|
5
|
-
type Moderation,
|
|
6
|
-
type ModerationType,
|
|
7
|
-
} from "#src/types";
|
|
8
|
-
import { type QueryResult } from "pg";
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
export function findPendingModerationFactory({ pg }: DatabaseContext) {
|
|
13
|
-
return async function findPendingModeration({
|
|
14
|
-
user_id,
|
|
15
|
-
organization_id,
|
|
16
|
-
type,
|
|
17
|
-
}: {
|
|
18
|
-
user_id: number;
|
|
19
|
-
organization_id: number;
|
|
20
|
-
type: ModerationType;
|
|
21
|
-
}) {
|
|
22
|
-
const { rows }: QueryResult<Moderation> = await pg.query(
|
|
23
|
-
`
|
|
24
|
-
SELECT *
|
|
25
|
-
FROM moderations
|
|
26
|
-
WHERE user_id = $1
|
|
27
|
-
AND organization_id = $2
|
|
28
|
-
AND type = $3
|
|
29
|
-
AND moderated_at IS NULL;`,
|
|
30
|
-
[user_id, organization_id, type],
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return rows.shift();
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { findRejectedModerationFactory } from "./find-rejected-moderation.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const findRejectedModeration = findRejectedModerationFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("findRejectedModerationFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should return undefined when no rejected moderation exists", async () => {
|
|
17
|
-
const moderation = await findRejectedModeration({
|
|
18
|
-
user_id: 1,
|
|
19
|
-
organization_id: 1,
|
|
20
|
-
type: "organization_join_block",
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
assert.equal(moderation, undefined);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("should return the rejected moderation", async () => {
|
|
27
|
-
await pg.sql`
|
|
28
|
-
INSERT INTO organizations
|
|
29
|
-
(cached_libelle, cached_nom_complet, id, siret, created_at, updated_at)
|
|
30
|
-
VALUES
|
|
31
|
-
('Necron', 'Necrontyr', 1, '⚰️', '1967-12-19', '1967-12-19')
|
|
32
|
-
;
|
|
33
|
-
`;
|
|
34
|
-
await pg.sql`
|
|
35
|
-
INSERT INTO users
|
|
36
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
37
|
-
VALUES
|
|
38
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
39
|
-
;
|
|
40
|
-
`;
|
|
41
|
-
await pg.sql`
|
|
42
|
-
INSERT INTO moderations
|
|
43
|
-
(id, user_id, organization_id, type, status, moderated_at, created_at)
|
|
44
|
-
VALUES
|
|
45
|
-
(1, 1, 1, 'organization_join_block', 'rejected', '4444-04-04', '4444-04-04')
|
|
46
|
-
;
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
const moderation = await findRejectedModeration({
|
|
50
|
-
user_id: 1,
|
|
51
|
-
organization_id: 1,
|
|
52
|
-
type: "organization_join_block",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
assert.equal(moderation?.id, 1);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ModerationStatusSchema,
|
|
5
|
-
type DatabaseContext,
|
|
6
|
-
type Moderation,
|
|
7
|
-
type ModerationType,
|
|
8
|
-
} from "#src/types";
|
|
9
|
-
import { type QueryResult } from "pg";
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
export function findRejectedModerationFactory({ pg }: DatabaseContext) {
|
|
14
|
-
return async function findRejectedModeration({
|
|
15
|
-
user_id,
|
|
16
|
-
organization_id,
|
|
17
|
-
type,
|
|
18
|
-
}: {
|
|
19
|
-
user_id: number;
|
|
20
|
-
organization_id: number;
|
|
21
|
-
type: ModerationType;
|
|
22
|
-
}) {
|
|
23
|
-
const { rows }: QueryResult<Moderation> = await pg.query(
|
|
24
|
-
`
|
|
25
|
-
SELECT *
|
|
26
|
-
FROM moderations
|
|
27
|
-
WHERE user_id = $1
|
|
28
|
-
AND organization_id = $2
|
|
29
|
-
AND type = $3
|
|
30
|
-
AND moderated_at IS NOT NULL
|
|
31
|
-
AND status = $4;`,
|
|
32
|
-
[user_id, organization_id, type, ModerationStatusSchema.enum.rejected],
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return rows.shift();
|
|
36
|
-
};
|
|
37
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { findBySiretFactory } from "./find-by-siret.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const findBySiret = findBySiretFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("findBySiretFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should find the organization by siret", async () => {
|
|
17
|
-
await pg.sql`
|
|
18
|
-
INSERT INTO organizations
|
|
19
|
-
(cached_libelle, cached_nom_complet, id, siret, created_at, updated_at)
|
|
20
|
-
VALUES
|
|
21
|
-
('Necron', 'Necrontyr', 1, '⚰️', '1967-12-19', '1967-12-19')
|
|
22
|
-
;
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
const organization = await findBySiret("⚰️");
|
|
26
|
-
|
|
27
|
-
assert.equal(organization?.id, 1);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("should return undefined when siret does not exist", async () => {
|
|
31
|
-
const organization = await findBySiret("absent");
|
|
32
|
-
|
|
33
|
-
assert.equal(organization, undefined);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type { DatabaseContext, Organization } from "#src/types";
|
|
4
|
-
import { type QueryResult } from "pg";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export function findBySiretFactory({ pg }: DatabaseContext) {
|
|
9
|
-
return async function findBySiret(siret: string) {
|
|
10
|
-
const { rows }: QueryResult<Organization> = await pg.query(
|
|
11
|
-
`
|
|
12
|
-
SELECT *
|
|
13
|
-
FROM organizations
|
|
14
|
-
WHERE siret = $1
|
|
15
|
-
`,
|
|
16
|
-
[siret],
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
return rows.shift();
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { findPendingByUserIdFactory } from "./find-pending-by-user-id.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const findPendingByUserId = findPendingByUserIdFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("findPendingByUserIdFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should return empty array when user has no pending moderations", async () => {
|
|
17
|
-
const organizations = await findPendingByUserId(42);
|
|
18
|
-
|
|
19
|
-
assert.deepEqual(organizations, []);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("should return pending organizations for a user", async () => {
|
|
23
|
-
await pg.sql`
|
|
24
|
-
INSERT INTO organizations
|
|
25
|
-
(cached_libelle, cached_nom_complet, id, siret, created_at, updated_at)
|
|
26
|
-
VALUES
|
|
27
|
-
('Necron', 'Necrontyr', 1, '⚰️', '1967-12-19', '1967-12-19')
|
|
28
|
-
;
|
|
29
|
-
`;
|
|
30
|
-
await pg.sql`
|
|
31
|
-
INSERT INTO users
|
|
32
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
33
|
-
VALUES
|
|
34
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
35
|
-
;
|
|
36
|
-
`;
|
|
37
|
-
await pg.sql`
|
|
38
|
-
INSERT INTO moderations
|
|
39
|
-
(id, user_id, organization_id, type, created_at, moderated_at, comment)
|
|
40
|
-
VALUES
|
|
41
|
-
(1, 1, 1, 'organization_join_block', '4444-04-04', NULL, 'pending')
|
|
42
|
-
;
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
const organizations = await findPendingByUserId(1);
|
|
46
|
-
|
|
47
|
-
assert.equal(organizations.length, 1);
|
|
48
|
-
assert.equal(organizations[0]?.id, 1);
|
|
49
|
-
assert.equal(organizations[0]?.moderation_id, 1);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type { DatabaseContext } from "#src/types";
|
|
4
|
-
import { ModerationTypeSchema, type Organization } from "#src/types";
|
|
5
|
-
import { type QueryResult } from "pg";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
export function findPendingByUserIdFactory({ pg }: DatabaseContext) {
|
|
10
|
-
return async function findPendingByUserId(user_id: number) {
|
|
11
|
-
const { rows }: QueryResult<Organization & { moderation_id: number }> =
|
|
12
|
-
await pg.query(
|
|
13
|
-
`
|
|
14
|
-
SELECT o.*, m.id as moderation_id
|
|
15
|
-
FROM moderations m
|
|
16
|
-
INNER JOIN organizations o on o.id = m.organization_id
|
|
17
|
-
WHERE m.user_id = $1
|
|
18
|
-
AND m.type = $2
|
|
19
|
-
AND m.moderated_at IS NULL
|
|
20
|
-
ORDER BY m.created_at
|
|
21
|
-
`,
|
|
22
|
-
[user_id, ModerationTypeSchema.enum.organization_join_block],
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
return rows;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { findByResetPasswordTokenFactory } from "./find-by-reset-password-token.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const findByResetPasswordToken = findByResetPasswordTokenFactory({
|
|
11
|
-
pg: pg as any,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
suite("findByResetPasswordTokenFactory", () => {
|
|
15
|
-
before(migrate);
|
|
16
|
-
beforeEach(emptyDatabase);
|
|
17
|
-
|
|
18
|
-
test("should find a user by reset_password_token", async () => {
|
|
19
|
-
await pg.sql`
|
|
20
|
-
INSERT INTO users
|
|
21
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job, reset_password_token)
|
|
22
|
-
VALUES
|
|
23
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque', 'TOKEN')
|
|
24
|
-
;
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
const user = await findByResetPasswordToken("TOKEN");
|
|
28
|
-
|
|
29
|
-
assert.equal(user?.id, 1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("should return undefined when the token does not exist", async () => {
|
|
33
|
-
const user = await findByResetPasswordToken("absent");
|
|
34
|
-
|
|
35
|
-
assert.equal(user, undefined);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type { DatabaseContext, User } from "#src/types";
|
|
4
|
-
import { type QueryResult } from "pg";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export function findByResetPasswordTokenFactory({ pg }: DatabaseContext) {
|
|
9
|
-
return async function findByResetPasswordToken(reset_password_token: string) {
|
|
10
|
-
const { rows }: QueryResult<User> = await pg.query(
|
|
11
|
-
`
|
|
12
|
-
SELECT *
|
|
13
|
-
FROM users WHERE reset_password_token = $1
|
|
14
|
-
`,
|
|
15
|
-
[reset_password_token],
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
return rows.shift();
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { getMemberIdsPromotedByDomain } from "#src/services/organization";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { describe, it } from "node:test";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
describe("getMemberIdsPromotedByDomain", () => {
|
|
10
|
-
it("should promote unverified and super weak members of the domain", () => {
|
|
11
|
-
assert.deepEqual(
|
|
12
|
-
getMemberIdsPromotedByDomain({
|
|
13
|
-
domain: "darkangels.world",
|
|
14
|
-
members: [
|
|
15
|
-
{
|
|
16
|
-
email: "lion.eljonson@darkangels.world",
|
|
17
|
-
id: 1,
|
|
18
|
-
verification_type: "no_validation_means_available",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
email: "cat.eljonson@darkangels.world",
|
|
22
|
-
id: 2,
|
|
23
|
-
verification_type:
|
|
24
|
-
"no_verification_means_for_entreprise_unipersonnelle",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
email: "tiger.eljonson@darkangels.world",
|
|
28
|
-
id: 3,
|
|
29
|
-
verification_type: "no_verification_means_for_small_association",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
email: "wolf.eljonson@darkangels.world",
|
|
33
|
-
id: 4,
|
|
34
|
-
verification_type: "no_verification_means_for_small_organization",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
email: "mouse.eljonson@darkangels.world",
|
|
38
|
-
id: 5,
|
|
39
|
-
verification_type: "domain_not_verified_yet",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
}),
|
|
43
|
-
[1, 2, 3, 4, 5],
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should not promote members of another domain", () => {
|
|
48
|
-
assert.deepEqual(
|
|
49
|
-
getMemberIdsPromotedByDomain({
|
|
50
|
-
domain: "darkangels.world",
|
|
51
|
-
members: [
|
|
52
|
-
{
|
|
53
|
-
email: "foo@bar.world",
|
|
54
|
-
id: 1,
|
|
55
|
-
verification_type: "no_validation_means_available",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
email: "luther@sub.darkangels.world",
|
|
59
|
-
id: 2,
|
|
60
|
-
verification_type: "no_validation_means_available",
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
}),
|
|
64
|
-
[],
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("should not promote members with a verified link", () => {
|
|
69
|
-
assert.deepEqual(
|
|
70
|
-
getMemberIdsPromotedByDomain({
|
|
71
|
-
domain: "darkangels.world",
|
|
72
|
-
members: [
|
|
73
|
-
{
|
|
74
|
-
email: "lion.eljonson@darkangels.world",
|
|
75
|
-
id: 1,
|
|
76
|
-
verification_type: "organization_dirigeant",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
email: "azrael@darkangels.world",
|
|
80
|
-
id: 2,
|
|
81
|
-
verification_type: "domain",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
email: "belial@darkangels.world",
|
|
85
|
-
id: 3,
|
|
86
|
-
verification_type: "official_contact_email",
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
}),
|
|
90
|
-
[],
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("should not promote anyone without members", () => {
|
|
95
|
-
assert.deepEqual(
|
|
96
|
-
getMemberIdsPromotedByDomain({ domain: "darkangels.world", members: [] }),
|
|
97
|
-
[],
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { SuperWeakLinkEnum, UnverifiedLinkEnum } from "#src/types";
|
|
4
|
-
import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export function getMemberIdsPromotedByDomain({
|
|
9
|
-
domain,
|
|
10
|
-
members,
|
|
11
|
-
}: {
|
|
12
|
-
domain: string;
|
|
13
|
-
members: ReadonlyArray<{
|
|
14
|
-
email: string;
|
|
15
|
-
id: number;
|
|
16
|
-
verification_type: string;
|
|
17
|
-
}>;
|
|
18
|
-
}) {
|
|
19
|
-
return members
|
|
20
|
-
.filter(
|
|
21
|
-
({ email, verification_type }) =>
|
|
22
|
-
getEmailDomain(email) === domain &&
|
|
23
|
-
(UnverifiedLinkEnum.safeParse(verification_type).success ||
|
|
24
|
-
SuperWeakLinkEnum.safeParse(verification_type).success),
|
|
25
|
-
)
|
|
26
|
-
.map(({ id }) => id);
|
|
27
|
-
}
|