Skip to content

Commit c4fabd5

Browse files
authored
Merge pull request #340 from paullallier/conf_code_predef_feat
feat(confirmationCodes): add CODE environment variable to pre-define code
2 parents afb5bfd + 9143469 commit c4fabd5

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ For example:
482482

483483
If a Custom Message lambda is configured, the output of the function invocation will be printed in the console too (verbosely!).
484484

485+
By default, confirmation codes are randomly generated. If set, the value assigned to the `CODE` environment variable will always be returned instead.
486+
485487
## Advanced
486488

487489
### Debugging Cognito Local

src/services/otp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const otp = (): string =>
2+
process.env.CODE ??
23
Math.floor(Math.random() * 999999)
34
.toString()
45
.padStart(6, "0");

src/targets/adminCreateUser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const AdminCreateUser =
120120
const now = clock.get();
121121

122122
const temporaryPassword =
123-
req.TemporaryPassword ?? generator.new().slice(0, 6);
123+
req.TemporaryPassword ?? process.env.CODE ?? generator.new().slice(0, 6);
124124

125125
const isEmailUsername =
126126
config.UserPoolDefaults.UsernameAttributes?.includes("email");

0 commit comments

Comments
 (0)