Update TotpBean.java

Add a `getUsername()` method to the `TotpBean` class so usernames can be used in the TOTP templates.
This commit is contained in:
summersab 2023-02-08 09:07:35 -06:00 committed by Pedro Igor
parent 4f068fcdcc
commit a64f6dcfc2

View file

@ -47,10 +47,12 @@ public class TotpBean {
private UriBuilder uriBuilder; private UriBuilder uriBuilder;
private final List<CredentialModel> otpCredentials; private final List<CredentialModel> otpCredentials;
private final List<String> supportedApplications; private final List<String> supportedApplications;
private final UserModel user;
public TotpBean(KeycloakSession session, RealmModel realm, UserModel user, UriBuilder uriBuilder) { public TotpBean(KeycloakSession session, RealmModel realm, UserModel user, UriBuilder uriBuilder) {
this.session = session; this.session = session;
this.realm = realm; this.realm = realm;
this.user = user;
this.uriBuilder = uriBuilder; this.uriBuilder = uriBuilder;
this.enabled = user.credentialManager().isConfiguredFor(OTPCredentialModel.TYPE); this.enabled = user.credentialManager().isConfiguredFor(OTPCredentialModel.TYPE);
if (enabled) { if (enabled) {
@ -107,4 +109,8 @@ public class TotpBean {
return otpCredentials; return otpCredentials;
} }
public String getUsername() {
return user.getUsername();
}
} }