Skip to content

Instantly share code, notes, and snippets.

@charltoons
Created August 26, 2017 14:21
Show Gist options
  • Save charltoons/9f13f7c4993420ca23013ee33a3a4619 to your computer and use it in GitHub Desktop.
Save charltoons/9f13f7c4993420ca23013ee33a3a4619 to your computer and use it in GitHub Desktop.
AWS Cognito Lambda PreSignup Auto-Confirm Trigger
'use strict';
exports.handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2))
const modifiedEvent = event
// check that we're acting on the right trigger
if (event.triggerSource === "PreSignUp_SignUp"){
// auto confirm the user
modifiedEvent.response.autoConfirmUser = true
callback(null, modifiedEvent)
return
}
// Throw an error if invoked from the wrong trigger
callback(`Misconfigured Cognito Trigger ${ event.triggerSource }`)
};
@andypmw
Copy link

andypmw commented Aug 1, 2018

Thank you!

@sivapictuscode
Copy link

sivapictuscode commented Aug 9, 2018

Thank you...

exports.handler = (event, context, callback) => {
event.response.autoConfirmUser=true;
callback(null, event);
};

@coalaroot
Copy link

this just saved the day <3

@mattysads
Copy link

There's no reason to call const modifiedEvent = event

Reassigning a reference does not affect the underlying object. Event is still modified here and cognito is fine with that

@tcchau
Copy link

tcchau commented Jul 31, 2019

@mattysads this little trick will suppress linter errors that tell you not to modify function arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment