I’ve observed that Auth0 Lock skips the Post-Registration step and runs in the background, causing issues such as missing user data in our database when the redirect occurs.
For instance:
Auth0 Lock → Skips Post-Registration (Auth0 actions) → Redirects → API fails due to incomplete user data in our database
Expected behavior:
Auth0 Lock → Waits and completes Post-Registration first → Redirects → API succeeds
We utilize Post-Registration (Auth0 action) to save user data to the database.
I’m uncertain why it’s skipping the Post-Registration step and proceeding directly to the redirect.
Here’s a code example:
const axios = require("axios");
/**
* Handler that will be called during the execution of a PostUserRegistration flow.
*
* @param {Event} event - Details about the context and user that has registered.
* @param {PostUserRegistrationAPI} api - Methods and utilities to help change the behavior after a signup.
*/
exports.onExecutePostUserRegistration = async (event, api) => {
console.log(JSON.stringify(event));
console.log("Saving user Data");
// create user in our db
await axios
.post(`https://exampleco.com/user`, {
...event.user,
})
.then((res) => {
console.log(`statusCode: ${res.status}`);
})
.catch((err) => {
console.error(err);
});
console.log("Saved user Data");
};