Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login method locale is not changing the user locale when the user logs in #542

Open
maripop opened this issue Feb 16, 2024 · 0 comments
Open

Comments

@maripop
Copy link

maripop commented Feb 16, 2024

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search for issues before submitting
- [ ] feature request

Versions.

angular: 16.2.0
keycloak-angular: 14.1.0
keycloak-js: 22.0.4
keycloak: 19.0.1

Repro steps.

Using an instance of KeycloakService we have implemented the login. First calling init with configuration, client and realm data. If not logged, we call the KeycloakService instance login method with action login and the chosen locale.

import { Injectable } from "@angular/core";
import { KeycloakService } from "keycloak-angular";

@Injectable()
export class KeycloakAdapter {
  keycloakInstance: KeycloakService;

  constructor() {
    this.keycloakInstance = new KeycloakService();
  }

  login(locale: string): void {
    this.keycloakInstance
      .init({
        config: {
          realm: "real_name",
          clientId: "client_id",
          url: "KEYCLOAK_URL",
        },
        initOptions: {
          onLoad: "check-sso",
          enableLogging: true,
          messageReceiveTimeout: 5000,
        },
      })
      .then((loggedIn: boolean) => {
        if (!loggedIn) {
          this.keycloakInstance.login({ action: "login", locale });
        } else {
          // logged actions
        }
      });
  }
}

This is redirecting to keycloak login with ui_locale parameter setted with the locale passed. The keycloak login is shown translated with this locale and the language selector has this locale selected. In keycloak, the realm authentication configuration has the "update user locale" required action enable.

imagen

The issue is that, when the user logs in, the user locale is not changed, so remains the previous one.
The user locale only is already changed when the locale is changed in keycloak login page, but not with the locale passed with KeycloakService login method. When the user changes the locale in keycloak login page, the url parametter setted with the chosen one is kc_locale instead of ui_locale.

imagen

Desired functionality.

The expected behavior is that, the locale passed to KeycloakService login method and setted in keyclok url ui_locale parametter, changes the user locale when the user logs in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant