I’m using Auth0 - JS library to sign up the users. I created a rule to send an e-mail after the user sign up, but this rule has not being called.
Rule code:
function(user, context, callback) {
console.log('THIS LOG MESSAGE DOES NOT APPEAR ON AUTH0 LOGS');
user.app_metadata = user.app_metadata || {};
if (!user.app_metadata.signedUp) {
return callback(null, user, context);
}
... SEND EMAIL WITH SENDGRID HERE
Sign up code:
export const auth0 = require('auth0-js');
auth.redirect.signupAndLogin( ... )
Ref: https://auth0.com/forum/t/how-to-send-email-to-admin-when-user-registers/2987/2
Technically, I could not reproduce the situation regarding the console.log
statement as the first statement of a rule. The message was correctly shown on the Webtask Real-time Logs extension; have in mind that these messages will not appear in the Logs section of the Dashboard which is meant to logs associated with known events.
In addition, the logic of the rule that you included is implemented in a way that does not seem correct as you seem to be performing the signup directly from the client application using the public endpoint for signup. This means that the user will be created without app_metadata
, which then causes the rule to initialize it to an empty object { }
.
If the app_metadata
is an empty object then !user.app_metadata.signedUp
will always evaluate to true
because the signedUp
property won’t exist which is a falsy value that is negated to become true
and in such way terminate rule execution without sending the email. If you’re setting the signedUp
property after sending the email, then you should fix the first condition and remove the negation operator.