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:

  1. Log in to the UI and receive an error code in response to the login, e.g. with basic auth. See below

  2. 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.

  1. Copy the default configuration for client.login.errors from client-config-default.json to client-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" } ], [...] }

     

  2. For your specific cases, get the code and message 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.

    1. The value of the message attribute must match the string from the server. So in this case, the message would be User disabled.

    2. You can set any value for the code. Abiquo will use it to identify your custom error message text in the lang_XX_custom.json files.

  3. So after the default login errors, you would add the following configuration to client-config-custom.json.

     

  4. 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.

Display a custom error when user login fails
Display a custom error when user login fails

 

Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved