From 4996aa418395db8fcd477fb3c26047ed21a1d4ce Mon Sep 17 00:00:00 2001 From: James Gregory Date: Thu, 25 Nov 2021 18:08:47 +1100 Subject: [PATCH] fix(api): adminCreateUser defaults status to FORCE_CHANGE_PASSWORD --- integration-tests/aws-sdk/adminCreateUser.test.ts | 2 +- integration-tests/aws-sdk/listUsers.test.ts | 2 +- src/services/userPoolClient.ts | 6 +++++- src/targets/adminCreateUser.test.ts | 2 +- src/targets/adminCreateUser.ts | 5 ++--- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/integration-tests/aws-sdk/adminCreateUser.test.ts b/integration-tests/aws-sdk/adminCreateUser.test.ts index d4a9bada..bb95a667 100644 --- a/integration-tests/aws-sdk/adminCreateUser.test.ts +++ b/integration-tests/aws-sdk/adminCreateUser.test.ts @@ -36,7 +36,7 @@ describe( Enabled: true, UserCreateDate: roundedDate, UserLastModifiedDate: roundedDate, - UserStatus: "CONFIRMED", + UserStatus: "FORCE_CHANGE_PASSWORD", Username: "abc", }, }); diff --git a/integration-tests/aws-sdk/listUsers.test.ts b/integration-tests/aws-sdk/listUsers.test.ts index 0efdfd0b..d4a50ddb 100644 --- a/integration-tests/aws-sdk/listUsers.test.ts +++ b/integration-tests/aws-sdk/listUsers.test.ts @@ -27,7 +27,7 @@ describe( Enabled: true, UserCreateDate: createUserResult.User?.UserCreateDate, UserLastModifiedDate: createUserResult.User?.UserLastModifiedDate, - UserStatus: "CONFIRMED", + UserStatus: "FORCE_CHANGE_PASSWORD", Username: "abc", }, ], diff --git a/src/services/userPoolClient.ts b/src/services/userPoolClient.ts index 9e526938..db69dd15 100644 --- a/src/services/userPoolClient.ts +++ b/src/services/userPoolClient.ts @@ -45,7 +45,11 @@ export interface User { UserCreateDate: number; UserLastModifiedDate: number; Enabled: boolean; - UserStatus: "CONFIRMED" | "UNCONFIRMED" | "RESET_REQUIRED"; + UserStatus: + | "CONFIRMED" + | "FORCE_CHANGE_PASSWORD" + | "RESET_REQUIRED" + | "UNCONFIRMED"; Attributes: AttributeListType; MFAOptions?: MFAOptionListType; diff --git a/src/targets/adminCreateUser.test.ts b/src/targets/adminCreateUser.test.ts index 291eae44..971157e0 100644 --- a/src/targets/adminCreateUser.test.ts +++ b/src/targets/adminCreateUser.test.ts @@ -44,7 +44,7 @@ describe("AdminCreateUser target", () => { Password: "pwd", UserCreateDate: now.getTime(), UserLastModifiedDate: now.getTime(), - UserStatus: "CONFIRMED", // TODO: this is wrong + UserStatus: "FORCE_CHANGE_PASSWORD", Username: "user-supplied", }); }); diff --git a/src/targets/adminCreateUser.ts b/src/targets/adminCreateUser.ts index a26ef87c..602077db 100644 --- a/src/targets/adminCreateUser.ts +++ b/src/targets/adminCreateUser.ts @@ -34,7 +34,7 @@ export const AdminCreateUser = ({ Password: req.TemporaryPassword, Attributes: attributes, Enabled: true, - UserStatus: "CONFIRMED", + UserStatus: "FORCE_CHANGE_PASSWORD", ConfirmationCode: undefined, UserCreateDate: now.getTime(), UserLastModifiedDate: now.getTime(), @@ -44,7 +44,6 @@ export const AdminCreateUser = ({ // TODO: should handle existing users // TODO: should send a message unless MessageAction=="SUPPRESS" // TODO: support MessageAction=="RESEND" - // TODO: UserStatus should default to FORCE_CHANGE_PASSWORD // TODO: should generate a TemporaryPassword if one isn't set // TODO: support ForceAliasCreation // TODO: support PreSignIn lambda and ValidationData @@ -54,7 +53,7 @@ export const AdminCreateUser = ({ Username: req.Username, Attributes: attributes, Enabled: true, - UserStatus: "CONFIRMED", + UserStatus: "FORCE_CHANGE_PASSWORD", UserCreateDate: now, UserLastModifiedDate: now, MFAOptions: undefined,