Auth0 Home Blog Docs

Auth0 is not defined in /dbconnections/signup

auth0
rules
database-connections

#1

I’ve enabled default Username-Password-Authentication and can’t make it work.
POST /dbconnections/signup returns

{ "name":"SandboxUnhandledError", "message":"auth0 is not defined", "fromSandbox":true, "stack":"ReferenceError: auth0 is not defined\n at connection.name (/data/io/2130cb1d-0410-401c-9359-15f0881edba4/webtask.js:6:150)\n at /data/io/2130cb1d-0410-401c-9359-15f0881edba4/webtask.js:6:333\n at Async.waterfall.Errors.create.code (/data/sandbox/lib/sandbox.js:558:33)\n at nextTask (/data/sandbox/node_modules/async/dist/async.js:5310:14)\n at next (/data/sandbox/node_modules/async/dist/async.js:5317:9)\n at /data/sandbox/node_modules/async/dist/async.js:958:16\n at /data/sandbox/lib/sandbox.js:447:24\n at nextTask (/data/sandbox/node_modules/async/dist/async.js:5310:14)\n at next (/data/sandbox/node_modules/async/dist/async.js:5317:9)\n at /data/sandbox/node_modules/async/dist/async.js:958:16" }

I’ve tried to disable all rules but it’s not helping. Seems to be some internal error.


#2

Typically, this error will occur when a script in one of your rules, database scripts or hooks makes use of the auth0 object without it being defined first. Since you mention that you’re using the default Username-Password-Authentication (with Use my own database disabled) and that you’ve disabled all rules, you can also check your [hooks] (https://manage.auth0.com/#/hooks), specifically the “Pre User Registration” and “Post User Registration” will run on the /dbconnections/signup case.


#3

I have only one hook and it does not use auth0 variable. I’ve dissabled it too but it still return the error

Here is the signup link


#4

https://moonmail.auth0.com/login?client=M5mJc6TZpF3fZZzseOMMCAKETlSTkPvM&protocol=oauth2&redirect_uri=https%3A%2F%2Fmanage.auth0.com%2Ftester%2Fcallback%3Fconnection%3DUsername-Password-Authentication&prompt=consent&response_type=code&connection=Username-Password-Authentication&scope=openid%20profile&state=L4FovoRdJtyx2Ye8reEuHya8PRbxpmlZ


#5

Could you share a snippet of code from your authentication request?


#6

No snippet at all, even if I go to connections -> database and click try there is the same error on auth0 hosted page

This is the url:

https://moonmail.auth0.com/login?client=M5mJc6TZpF3fZZzseOMMCAKETlSTkPvM&protocol=oauth2&redirect_uri=https://manage.auth0.com/tester/callback?connection=Username-Password-Authentication&prompt=consent&response_type=code&connection=Username-Password-Authentication&scope=openid profile&state=zi_q2Lcu5p2CVmcFlqFK2nNtsp-FH_XK


#7

The problem persists, and even hosted page with default config returns the same error.
Is there anything I can do?

Hosted Page Login


#8

The problem persists, and even hosted page with default config returns the same error.
Is there anything I can do?

Hosted Page Login


#9

@dmitriy.nevzorov Are you getting this issue in the moonmail tenant? Do you see any logs in the dashboard when you call /dbconnections/signup and get this error back?


#10

Yes, it is in moonmail tenant.
This is an error from Webtask Logs

{
  "code": 500,
  "error": "Script generated an unhandled synchronous exception.",
  "details": "ReferenceError: auth0 is not defined",
  "name": "ReferenceError",
  "message": "auth0 is not defined",
  "stack": "ReferenceError: auth0 is not defined\n    at connection.name (/data/io/5f5ac665-f16e-47a8-b77d-2d0b775029a5/webtask.js:6:150)\n    at /data/io/5f5ac665-f16e-47a8-b77d-2d0b775029a5/webtask.js:6:333\n    at Async.waterfall.Errors.create.code (/data/sandbox/lib/sandbox.js:558:33)\n    at nextTask (/data/sandbox/node_modules/async/dist/async.js:5310:14)\n    at next (/data/sandbox/node_modules/async/dist/async.js:5317:9)\n    at /data/sandbox/node_modules/async/dist/async.js:958:16\n    at /data/sandbox/lib/sandbox.js:447:24\n    at nextTask (/data/sandbox/node_modules/async/dist/async.js:5310:14)\n    at next (/data/sandbox/node_modules/async/dist/async.js:5317:9)\n    at /data/sandbox/node_modules/async/dist/async.js:958:16"
}

#11

I’ve tried all possible ways to locate the email but it seems to be somewhere on auth0 side. We never used db connection in moonmail so maybe something got broken with internal upgrades?


#12

@dmitriy.nevzorov This seems to indicate a problem with the rules, hooks or custom database scripts. I’ve seen that you have a auth0.users.updateAppMetadata in your rules. Just to confirm if the issue is with that object, could you try disabling all rules and hooks, enable the Username-Password-Authentication connection for a client and then triggering the hosted login page with Auth0.js for that client?


#13

I’ve tried it multiple times and just did it again right now. The issue persists. Maybe there are some hidden rules or hooks I cant see?


#14

It appears that you have a user_registration rule in your tenant, probably set a long time ago. This stage has been deprecated in favour of the new hooks. You should remove this rule using the [DELETE /api/v2/rules/{id}] (https://auth0.com/docs/api/management/v2#!/Rules/delete_rules_by_id).

You can get the rule id by performing a (GET) request to /api/v2/rules?stage=user_registration, as shown in this community post: https://community.auth0.com/questions/1312/rules-for-user-registration-not-retrieved-via-mana


#15

Finally, this is it! Thank you very much!