From a3e47c9a9aa1e63bfa025d4d471cec28a15c50f5 Mon Sep 17 00:00:00 2001 From: Evert Pot Date: Thu, 25 Jul 2024 23:46:41 -0400 Subject: [PATCH] Bring back 'active' flag on user creation for BC --- schemas/principal-new.json | 4 ++++ src/api-types.ts | 4 ++++ src/user/controller/collection.ts | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/schemas/principal-new.json b/schemas/principal-new.json index a887298d..de852df0 100644 --- a/schemas/principal-new.json +++ b/schemas/principal-new.json @@ -14,6 +14,10 @@ "type": "string", "minLength": 3 }, + "active": { + "description": "Deprecated: If set, and when an identity href is passed when creating a user, this automatically sets that identity as 'verified'. This flag exists to replicate the behavior of older a12n-server versions when email verification was handled through the 'active' flag. This will be fully ignored in a future version and eventually removed.", + "type": "boolean" + }, "type": { "enum": ["user", "app", "group"] } diff --git a/src/api-types.ts b/src/api-types.ts index 1eb905c6..a30a729e 100644 --- a/src/api-types.ts +++ b/src/api-types.ts @@ -162,6 +162,10 @@ export interface PrincipalEdit { export interface PrincipalNew { _links?: unknown; nickname: string; + /** + * Deprecated: If set, and when an identity href is passed when creating a user, this automatically sets that identity as 'verified'. This flag exists to replicate the behavior of older a12n-server versions when email verification was handled through the 'active' flag. This will be fully ignored in a future version and eventually removed. + */ + active?: boolean; type: "user" | "app" | "group"; } /* eslint-disable */ diff --git a/src/user/controller/collection.ts b/src/user/controller/collection.ts index 26f72732..6662dbec 100644 --- a/src/user/controller/collection.ts +++ b/src/user/controller/collection.ts @@ -49,12 +49,18 @@ class UserCollectionController extends Controller { modifiedAt: new Date(), }); + if (ctx.request.body.active !== undefined) { + console.error('[ERROR] A API client used the "active" flag when creating a new user. This is deprecated behavior!'); + } + await services.principalIdentity.create({ principalId: user.id, isPrimary: true, uri: identity, label: null, - markVerified: false, + + // Deprecated feature. + markVerified: ctx.request.body.active ?? false, }); ctx.response.status = 201;