Login screen default username

Hello.

Sorry for all the questions as I’m still learning about Cuba, but I have another one.

Is there a way to default the username based on the user trying to access the system? We usually did this in our old application by passing a parameter in the URL such as http://localhost/app&userid=myuser
and this was handled automatically by Oracle Forms middleware.

Or, is the “remember me” on the login screen customizable? That is, can it just remember the username and not the password? For security reasons, I would not like it to remember the password, but username OK. Otherwise, I will have to turn the remember me functionality off.

Thanks.

These options in the app.properties file specify the default username and password in the login dialog

  • cuba.web.loginDialogDefaultUser
  • cuba.web.loginDialogDefaultPassword

If you want to read username from the URL, you need to extend login screen using the standard screen creation wizard and subscribe to the event urlParamsChanged

Then write something like this:

public void onUrlParamsChanged(UrlParamsChangedEvent event) {
    String userId = event.getParams().get("userid");
    if (!StringUtils.isEmpty(userId)) {
        loginField.setValue(userId);
    }
}

After that you will be able to pass userid parameter to the login screen using the following URL: http://localhost:8080/app/#login?userid=MyUserName

As a side note: “remember me” function does NOT remember password. It remembers authentication token obtained after successful login. It is a common practice and should not be prohibited by any security requirements.

Thanks Andrey. I will try this and see how it goes.

EDIT: It worked!

1 Like