Custom Login Page with Lock.js Defaults to Incorrect Database Connection on Login
Last Updated:
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.
-
Go to Branding > Universal Login.
-
Select Manage Classic Login.
-
Select the Login tab.
-
Locate the line containing the hardcoded connection variable within the defaultDatabaseConnection string setting in the
Lock.jsconfiguration:var databaseConnection = 'Default-database'; -
Replace that line with the following code to allow the
configobject to determine the connection:JavaScriptvar 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. -
Select Save to apply the changes.