Skip to content

Commit

Permalink
Bring back 'active' flag on user creation for BC
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Jul 26, 2024
1 parent 44a7aee commit a3e47c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions schemas/principal-new.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand Down
4 changes: 4 additions & 0 deletions src/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 7 additions & 1 deletion src/user/controller/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a3e47c9

Please sign in to comment.