Overview
This article explains whether there are any Action samples that show how to send a change password email after a user signs up.
Applies To
- Post User Registration
- Action
Solution
The following Post-User-Registration Action code will send a change password email once a user signs up:
Note that client ID is not currently available in a Post user registration trigger, but it may be possible to infer it from the event.transaction object via the redirect_uri for example. If no client ID is supplied, a tenant level default login route must be configured to provide a user with a “Back to…” button after submitting their new password. See Complete password reset flow for more details.
exports.onExecutePostUserRegistration = async (event, api) => {
var axios = require("axios").default;
const sendPasswordResetEmail = () => {
var options = {
method: 'POST',
url: 'https://YOUR_DOMAIN}/dbconnections/change_password',
headers: {'content-type': 'application/json'},
data: {
client_id: '<insertClientIDHere>',
email: 'event.user.email',
connection: 'event.connection.name'
}
};
try{
axios.request(options).then(function (response) {
console.log("Response: ",response.data);
})
}catch(error){
console.error(error)
}
}
}