I am migrating data from keycloak to auth0, As per auth0 email format is not allowed in username field. Due to this i have imported username as login_identifier in app_metadata
Refer to this below
[
{
"user_id" : "79b72656-7a50-4214-985e-fa537efe85e0",
"given_name": "test",
"family_name": "user",
"email": "test1@gmail.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "pbkdf2",
"hash": {
"value": "$pbkdf2-sha256$i=27500,l=64$5TXiLHDApo9xDKVk1Qsarw$D4VVb7Uo0QIo/4vulomwT43Sn99hMf3d5LaB8Ufi3BXPkZrWF7rcAdN+u3miltoYvkJIx2//roiDpvkdI+fU3A"
}
},
"app_metadata": {
"login_identifier": "test123@gmail.com"
}
}
]
I am trying to ensure that this login_identifier is used for login instead of email.
I have written a custom action : VALIDATE_USERNAME
exports.onExecutePostLogin = async (event, api) => {
// Extract the entered username (email-like) from the request
const enteredUsername = event.request.body.email;
// Extract the stored username from app_metadata
const storedUsername = event.user.app_metadata?.login_identifier;
// Check if entered username matches stored username
if (storedUsername != null && enteredUsername === storedUsername) {
// Allow login to proceed
return;
}
// Deny login if username doesn't match
throw new Error('Invalid username or password here in customs.');
};
After creating this action, i have added it to trigger : post-login
But this is not working as expected, Why is this post login trigger not working ?