Support passing in locale option to init() (#11760)

Closes #11759
This commit is contained in:
zyairzy 2023-06-27 15:19:13 +08:00 committed by GitHub
parent 36e85578be
commit bdb4dd8070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View file

@ -375,6 +375,7 @@ reference link:{adminguide_link}#_client_scopes[Client scopes] defined on a part
always added to the list of scopes by the adapter. For example, if you enter the scope options `address phone`, then the request always added to the list of scopes by the adapter. For example, if you enter the scope options `address phone`, then the request
to {project_name} will contain the scope parameter `scope=openid address phone`. to {project_name} will contain the scope parameter `scope=openid address phone`.
* messageReceiveTimeout - Set a timeout in milliseconds for waiting for message responses from the Keycloak server. This is used, for example, when waiting for a message during 3rd party cookies check. The default value is 10000. * messageReceiveTimeout - Set a timeout in milliseconds for waiting for message responses from the Keycloak server. This is used, for example, when waiting for a message during 3rd party cookies check. The default value is 10000.
* locale - When onLoad is 'login-required', sets the 'ui_locales' query param in compliance with https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest[section 3.1.2.1 of the OIDC 1.0 specification].
Returns a promise that resolves when initialization completes. Returns a promise that resolves when initialization completes.

View file

@ -195,6 +195,12 @@ export interface KeycloakInitOptions {
* @default 10000 * @default 10000
*/ */
messageReceiveTimeout?: number messageReceiveTimeout?: number
/**
* When onLoad is 'login-required', sets the 'ui_locales' query param in compliance with section 3.1.2.1
* of the OIDC 1.0 specification.
*/
locale?: string;
} }
export interface KeycloakLoginOptions { export interface KeycloakLoginOptions {

View file

@ -176,6 +176,9 @@ function Keycloak (config) {
options.prompt = 'none'; options.prompt = 'none';
} }
if (initOptions && initOptions.locale) {
options.locale = initOptions.locale;
}
kc.login(options).then(function () { kc.login(options).then(function () {
initPromise.setSuccess(); initPromise.setSuccess();
}).catch(function (error) { }).catch(function (error) {