Hi @sam_hatoum,
Thanks for reaching out to the Auth0 Community!
In your Action script, you will need to iterate through the event.user.identities
array of objects and search for the email
attribute in the profileData
object. Note that the first object in the array references the primary account. All other profiles are appended after the primary profile hence why the index begins from the second item. See below of an example.
exports.onExecutePostLogin = async (event, api) => {
var index = 1
while(event.user.identities[index]){
console.log("Email:", event.user.identities[index].profileData.email)
index += 1
}
};
Lastly, have you gotten a chance to take a look at the Auth0 Account Linking Extension? It should accomplish the same behavior you seek with Actions.
Please let me know how this goes for you.
Thanks!