I have two apps in the same tenant and I need a different behaviour for each one. For one of them I configured the password email verification defining (rules + hook) and it’s working fine. The other one requieres to send a validation email, but I cannot get it working.
Is there a way that both configurations coexist? How?
Based on what I have gathered, I believe that you are trying to perform email verification in different ways depending on the application in your tenant.
In the context of Rules, you can specify the context.clientID to perform the specific email verification for each application. See our Rules Context Object for more properties.
If I did not answer your question, please help me by answering further clarifying questions.
First, could you please elaborate on what is preventing you from having both configurations working together? Is there any specific errors or limitation stopping you?
Next, could you please clarify what you’d like to do with your second app regarding Rules and Hooks and how you intend to use them?
Based on what I have gathered, I believe that you are trying to perform email verification in different ways depending on the application in your tenant.
yes that’s exactly what I want.
I’ve tried to add a rule hitting …/api/v2/jobs/verification-email but it requires the Status toggle enabled for the verification email and the email sends twice. Related to this one, the email verification link works, it means the email sets as validated, but shows an error page.
I’ve also seen the one that you mentioned, but I don’t understand the payload:
How do I get secretToken, where is the place on dashboard to get it?
and then how to get “your api” & “your company”, are they my domain ? like https://TENANT_NAME.us.auth0.com ?
Yes, that is correct. By default, all newly signed up users will receive an Email Verification email when the **Email Verification ** template is enabled. Creating a rule to send an Email Verification email for unverified users using the Management API will also trigger this event, resulting in double sending emails.
To circumvent double sending emails, I recommend the following for a more frictionless approach:
Disable the Status for Email Verification template
Create a Rule that checks for the clientID of your second application, and then send a verification email using the Management API. Here is a plug & play code snippet using Rules, be sure to add the clientID of your second app:
function (user, context, callback) {
const ManagementClient = require('auth0@2.9.1').ManagementClient;
const management = new ManagementClient({
token: auth0.accessToken,
domain: auth0.domain
});
if(context.clientID === "YOUR_2ND_APP_CLIENT_ID"){
var params = {
user_id: user.user_id
};
management.sendEmailVerification(params, function (err) {
if (err) {
// Handle error.
}
});
}
return callback(null, user, context);
}
After doing so, this should allow you to have both applications with their own email verification approaches without interference or double sending emails. Moreover, this rule will only execute for your second app, and send Email Verification emails programmatically whenever a new user signs up.