Customize server errors when login fails
This page describes how to customize login errors in the Abiquo UI
When you log in to Abiquo, there can be two types of logins and login errors:
Log in to the UI and receive an error code in response to the login, e.g. with basic auth. See below
Log in via a portal and when there is an error, redirect to a URL, e.g. SAML.
See https://abiquo.atlassian.net/wiki/spaces/doc/pages/311377325
UI login errors
This section applies to Abiquo 6.1.1+
When a user tries to log in with basic auth or LDAP, but fails, the Abiquo server returns an error that you cannot customize as regular UI text. This type of error displays on a red popup toast message in the UI. This section explains how to add a custom message or translation for these errors.
The client-config-default.json
has the default configuration for some specific errors that we already handle in the UI.
"client.login.errors": [
{
"message": "Too many failed attempts to login",
"code": "401-TooManyAttempts"
},
{
"message": "User account is locked",
"code": "401-UserAccountLocked"
},
{
"message": "The supplied access token is not valid",
"code": "403-InvalidToken"
}
],
To specify a custom label for these cases, add a custom label in lang_XX_custom.json
for each case, for example:
{
"server.error.401-TooManyAttempts":"This is a custom label for error 'Too many failed attempts to login'",
"server.error.401-UserAccountLocked":"This is a custom label for error 'User account is locked'"
}
Define custom UI login error messages
Do these steps to add new custom errors for specific cases.
Copy the default configuration for
client.login.errors
fromclient-config-default.json
toclient-config-custom.json
{ [...] "client.login.errors": [ { "message": "Too many failed attempts to login", "code": "401-TooManyAttempts" }, { "message": "User account is locked", "code": "401-UserAccountLocked" }, { "message": "The supplied access token is not valid", "code": "403-InvalidToken" } ], [...] }
For your specific cases, get the
code
andmessage
attributes of the server error.
Here is an example. If you try to login with a disabled user, the server will return the following error.The value of the
message
attribute must match the string from the server. So in this case, themessage
would beUser disabled
.You can set any value for the
code
. Abiquo will use it to identify your custom error message text in thelang_XX_custom.json
files.
So after the default login errors, you would add the following configuration to
client-config-custom.json
.Add your custom error message text in all available language files:
lang_en_US_custom.json
,lang_es_ES_custom
and so on.
If you add the custom error labels in the default files:lang_XX_labels.json
, you will lose your changes when you update versions
After you add the custom message text, the custom error will display in the UI.
Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved