From c2fe500eb82dc425a8be062003a00d3a90d2b9f5 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Fri, 2 Feb 2018 13:32:47 +0200 Subject: [PATCH] [KEYCLOAK-4721] Consider Session Language of Realm Also In ReCaptcha --- .../authentication/forms/RegistrationRecaptcha.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/src/main/java/org/keycloak/authentication/forms/RegistrationRecaptcha.java b/services/src/main/java/org/keycloak/authentication/forms/RegistrationRecaptcha.java index 8e65450ced..360b1346fd 100755 --- a/services/src/main/java/org/keycloak/authentication/forms/RegistrationRecaptcha.java +++ b/services/src/main/java/org/keycloak/authentication/forms/RegistrationRecaptcha.java @@ -93,6 +93,7 @@ public class RegistrationRecaptcha implements FormAction, FormActionFactory, Con @Override public void buildPage(FormContext context, LoginFormsProvider form) { AuthenticatorConfigModel captchaConfig = context.getAuthenticatorConfig(); + String userLanguageTag = context.getSession().getContext().resolveLocale(context.getUser()).toLanguageTag(); if (captchaConfig == null || captchaConfig.getConfig() == null || captchaConfig.getConfig().get(SITE_KEY) == null || captchaConfig.getConfig().get(SITE_SECRET) == null @@ -103,7 +104,7 @@ public class RegistrationRecaptcha implements FormAction, FormActionFactory, Con String siteKey = captchaConfig.getConfig().get(SITE_KEY); form.setAttribute("recaptchaRequired", true); form.setAttribute("recaptchaSiteKey", siteKey); - form.addScript("https://www.google.com/recaptcha/api.js"); + form.addScript("https://www.google.com/recaptcha/api.js?hl=" + userLanguageTag); } @Override @@ -215,7 +216,7 @@ public class RegistrationRecaptcha implements FormAction, FormActionFactory, Con return "Adds Google Recaptcha button. Recaptchas verify that the entity that is registering is a human. This can only be used on the internet and must be configured after you add it."; } - private static final List configProperties = new ArrayList(); + private static final List CONFIG_PROPERTIES = new ArrayList(); static { ProviderConfigProperty property; @@ -224,19 +225,19 @@ public class RegistrationRecaptcha implements FormAction, FormActionFactory, Con property.setLabel("Recaptcha Site Key"); property.setType(ProviderConfigProperty.STRING_TYPE); property.setHelpText("Google Recaptcha Site Key"); - configProperties.add(property); + CONFIG_PROPERTIES.add(property); property = new ProviderConfigProperty(); property.setName(SITE_SECRET); property.setLabel("Recaptcha Secret"); property.setType(ProviderConfigProperty.STRING_TYPE); property.setHelpText("Google Recaptcha Secret"); - configProperties.add(property); + CONFIG_PROPERTIES.add(property); } @Override public List getConfigProperties() { - return configProperties; + return CONFIG_PROPERTIES; } }