DB Action Script - "Save and Try" Works, "Try Connection" Doesn't

Hello,

I’m new to Auth0 and have been struggling to implement it into our PHP application. I have the following database action script:

function login(email, password, callback) {
  const request = require('request');

  request.get({
    url: 'https://mydomain.example/[...],
    auth: {
      username: email,
      password: password
    }

  }, function(err, response, body) {
    
    console.log("We have a response");
    
    if (err || response.statusCode === 401){
      console.log("We hit a problem");
      return callback();
    }

    console.log("All looks normal");
    
    const resp = JSON.parse(body);
    const user = resp.user[0];
    
    callback(null, {
      user_id: user.user_id.toString(),
      nickname: user.name,
      email: user.email
    });
  });
}

If I run this from the DB Action Script page, using “Save and Try”, I get the user profile etc. but if I run this using the “Try Connection” (the Universal Login) I get a username or password issue. This is despite the console.log message showing that it had in fact gotten through to the success state which was also shown on the server side log.

Any ideas? I can’t find much documentation on what it is actually expecting as a callback. Our server will return 401 if the username and password fail.

Thanks

Hi @ashleigh,

Welcome to the Auth0 Community!

I understand that you have been encountering problems when trying to implement a Custom Database Connection.

First, could you please clarify the error messages that you observed?

In the meantime, you may find our Troubleshoot Custom Databases docs useful.

Looking forward to your response.

Thank you.

Hi rueben,

Many thanks for reaching out.

The error message that I receive, when trying it via the universal login page is “Wrong username or password” but the exact same details will pull the profile correctly in the sandbox/tester thing.

I think this can be marked as solved, I believe the issue to be related to my current subscription plan - many thanks for your help.

Hi @ashleigh,

Thank you for your responses.

Ah, yes! Using an External Database is only available to Professional and Enterprise subscription plans.

If applicable as a workaround, you could consider migrating your users into an Auth0 database using Bulk User Imports.

Please let me know if there’s anything else I can do to help.

Thank you.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.