We set some user attributes during the signup process using the following PreUserRegistration code.
exports.onExecutePreUserRegistration = async (event, api) => {
const user = event.user;
if (!user.email) {
api.access.deny("missing_information", "Please enter mandatory details.");
} else {
try {
// register user
const onboardingAPIUrl = `xxx`;
const onboardingObj = await axios.post(onboardingAPIUrl, params);
if (onboardingObj && onboardingObj.data) {
api.user.setUserMetadata("user_id", onboardingObj.data.user_id);
api.user.setUserMetadata(
"organization_id",
onboardingObj.data.organization_id
);
api.user.setUserMetadata(
"display_name",
onboardingObj.data.display_name
);
} else {
api.access.deny(
"onboarding_error1",
"System error. Please contact administrator."
);
}
} catch (error) {
api.access.deny(
"onboarding_error2",
"System error. Please contact administrator."
);
}
}
};
In the Login flow, we set the custom claim with user_metadata
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'xxxx';
if (event.authorization) {
api.accessToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
}
}
For the last few days, we have been getting empty custom claims for ${namespace}/user_metadata during the signup - first login only.
As soon as we refresh the screen or do a second login we get the user_metadata as before.
Is there any recent change that happened in the signup or login flow?
Can someone help me understand?