Hi, heres some sample code to help.
apistack.js
========
this.auth = new sst.Auth(this, "Auth", {
cognito: {
triggers: {
customMessage: {
handler: "services/cognito/customMessage.main",
},
preSignUp: {
handler: "services/cognito/preSignUp.main",
},
// preAuthentication: {
// handler: "services/cognito/preAuthentication.main",
_// // environment: { TABLE_NAME: props.table.tableName },_
// // permissions: [table],
// },
postConfirmation: {
handler: "services/cognito/postConfirmation.main",
environment: { TABLE_NAME: props.table.tableName },
permissions: [table],
},
},
custommessage.js
==============
export const main = (event, context, callback) => {
if(event.triggerSource === "CustomMessage_SignUp") {
// Ensure that your message contains event.request.codeParameter. This is the placeholder for code that will be sent
event.response.smsMessage = "Welcome to the service. Your confirmation code is " + event.request.codeParameter;
event.response.emailSubject = "Welcome to the service";
event.response.emailMessage = "Thank you for signing up. " + event.request.codeParameter + " is your verification code";
}
// Return to Amazon Cognito
callback(null, event);
};
I use the preSignup and postConfirmation. inside the postConfirmation i add the user to a separate DB table