Custom Login Page with Lock.js Defaults to Incorrect Database Connection on Login

Overview

This article describes an issue where the application defaults to the Default-database connection during authentication using Lock.js, even when the Not-Default-Database connection parameter is specified in the request.

Applies To

  • Universal Login
  • Custom Login Page
  • Database Connections
  • Lock.js

Cause

The issue occurs because the connection variable associated with the defaultDatabaseConnection option in the Lock.js configuration is explicitly hardcoded. This forces the authentication to validate against the default database, ignoring the incoming connection parameter. The config.connection variable is populated from the connection parameter of the /authorize request.

Solution

Follow these steps to modify the JavaScript to respect the incoming connection parameter.

  1. Go to Branding > Universal Login.

  2. Select Manage Classic Login.

  3. Select the Login tab.

  4. Locate the line containing the hardcoded connection variable within the defaultDatabaseConnection string setting in the Lock.js configuration:

    var databaseConnection = 'Default-database';
  5. Replace that line with the following code to allow the config object to determine the connection:

    JavaScript
    var databaseConnection = config.connection || 'Default-database';

    NOTE: This change ensures that if a connection is requested, the page uses it; otherwise, it defaults to Default-database.

  6. Select Save to apply the changes.

Recommended content

No recommended content found...