Auth0 Home Blog Docs

POST user registration hook returning "data/sandbox/node_modules...." error


#1

Hi Team,

I am trying to test a slack code in post user registration hook with the below code and run via console itself.Its returning the below error.Can any one help me?

Request :
module.exports = function (user, context, cb) {

var SLACK_HOOK ="#URL";

// Post the new user’s name and email address to the selected channel
var slack = require(‘slack-notify’)(SLACK_HOOK);
var message = ‘New User: ’ + (user.email) + ’ (’ + user.email + ‘)’;
var channel = ‘#CHANNEL’;

slack.success({
text: message,
channel: channel
});

console.log(“success”);
cb(message);
};

RESPONSE :

  "message": "New User: user1@foo.com (user1@foo.com)",
  "statusCode": 500,
  "stack": "Error: New User: user1@foo.com (user1@foo.com)\n    at respondWithError (/data/sandbox/node_modules/auth0-ext-compilers/lib/adapter.js:11:17)\n    at buildResponse (/data/sandbox/node_modules/auth0-ext-compilers/lib/adapter.js:96:24)\n    at func (/data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/user-registration.js:31:20)\n    at module.exports (/data/io/27e9ebc9-6a28-4784-a88d-85492b8359eb/webtask.js:19:3)\n    at Authz.is_authorized.error (/data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/user-registration.js:30:16)\n    at Object.is_authorized (/data/sandbox/node_modules/auth0-ext-compilers/lib/authorization.js:13:81)\n    at userRegistrationHandler (/data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/user-registration.js:9:18)\n    at parseBody (/data/sandbox/node_modules/auth0-ext-compilers/lib/adapter.js:90:20)\n    at finish (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/lib/index.js:369:16)\n    at wrapped (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/hoek/lib/index.js:879:20)"
}

Please can any one help?


#2

Hi @shilpa.c.kumar

Your issue is that you are using the cb (or callback) parameter incorrectly.
The callback parameter is a function which takes in three parameters, it has the following method signature:
function (error, user, context)

This means that if you pass a non-null value as the first parameter (as you are doing with cb(message);) it will be treated like the rule has failed.

If your rule succeeds then the callback should be called as so in your code:
cb(null, user, context);

For more information about rules you can find the docs here.


#3

Thanks [charsleysa] issue is resovled now. :slight_smile:


#4

Thanks a lot @charsleysa :clap:t3::clap:t3::clap:t3::clap:t3: