Skip to content

Commit

Permalink
feat(serverless-cognito-user-pool): add support for username attribut…
Browse files Browse the repository at this point in the history
…es and schema (#1160)
  • Loading branch information
Arun4you authored Jul 27, 2020
1 parent a019b25 commit fc9bebb
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/serverless-aws-cognito-user-pool/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@ class ServerlessAwsCognito extends Component {
this.context.instance.debug("Input was not changed, no action required.");
return this.state.output;
}

let schemaConfig = []
const {
region = "us-east-1",
name,
tags = {},
appClients = [],
allowSignup = false
allowSignup = false,
schema
} = inputs;
const passwordPolicy = Object.assign({}, defaultPasswordPolicy, inputs.passwordPolicy);

const usernameAttributes = inputs.usernameAttributes ? inputs.usernameAttributes : ["email"]
if(schema){
if(Array.isArray(schema)){
schemaConfig = [...schema]
}else{
throw Error(`Schema attributes needs to be passed in array.`);
}
}
const cognito = new Cognito({ region });
this.state.output = this.state.output || { appClients: [] };

Expand Down Expand Up @@ -139,13 +147,14 @@ class ServerlessAwsCognito extends Component {
Mutable: true,
Name: "given_name",
Required: true
}
},
...schemaConfig
],
UserPoolAddOns: {
AdvancedSecurityMode: "OFF" /* required */
},
UserPoolTags: Object.assign({}, tags),
UsernameAttributes: ["email"],
UsernameAttributes: [...usernameAttributes],
VerificationMessageTemplate: {
DefaultEmailOption: "CONFIRM_WITH_CODE"
}
Expand Down

0 comments on commit fc9bebb

Please sign in to comment.