From a64f6dcfc2ded4502797dce9453c292b0907df18 Mon Sep 17 00:00:00 2001 From: summersab <18727110+summersab@users.noreply.github.com> Date: Wed, 8 Feb 2023 09:07:35 -0600 Subject: [PATCH] Update TotpBean.java Add a `getUsername()` method to the `TotpBean` class so usernames can be used in the TOTP templates. --- .../org/keycloak/forms/login/freemarker/model/TotpBean.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/src/main/java/org/keycloak/forms/login/freemarker/model/TotpBean.java b/services/src/main/java/org/keycloak/forms/login/freemarker/model/TotpBean.java index 77bac99f82..4153ff51a2 100755 --- a/services/src/main/java/org/keycloak/forms/login/freemarker/model/TotpBean.java +++ b/services/src/main/java/org/keycloak/forms/login/freemarker/model/TotpBean.java @@ -47,10 +47,12 @@ public class TotpBean { private UriBuilder uriBuilder; private final List otpCredentials; private final List supportedApplications; + private final UserModel user; public TotpBean(KeycloakSession session, RealmModel realm, UserModel user, UriBuilder uriBuilder) { this.session = session; this.realm = realm; + this.user = user; this.uriBuilder = uriBuilder; this.enabled = user.credentialManager().isConfiguredFor(OTPCredentialModel.TYPE); if (enabled) { @@ -107,4 +109,8 @@ public class TotpBean { return otpCredentials; } + public String getUsername() { + return user.getUsername(); + } + }