legacy-knowledge-base
公開されました Jun. 30, 2025

How to change the generated OTP from alphanumeric to numeric in multi-factor authentication?

written-by

Pooja Bhambani

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

NOTE: The following resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.

Issue

  • The Multi-Factor Authentication (MFA) one-time password (OTP) is generated in an alphanumeric format. How can it be changed to numeric only?

Environment

  • Liferay DXP 7.4

Resolution

  • At the time of writing this article, there is no out-of-the-box feature available to change the password from alphanumeric to numeric only.
  • However, this requirement could be achieved by overriding SendMFAEmailOTPMVCResourceCommand class

Modify the following code:

@Component(
property = {
"javax.portlet.name=" + "com_liferay_multi_factor_authentication_portlet_web_internal_portlet_MFAEmailOTPVerifyPortlet",
"mvc.command.name=/mfa_email_otp_verify/send_mfa_email_otp",
"service.ranking:Integer=100"},
service = MVCResourceCommand.class)
public class SendMFAEmailOTPMVCResourceCommand implements MVCResourceCommand {
public static final String KEY1 = "0123456789";
private static final String[] _KEYS = {KEY1};

String generatedMFAEmailOTP = PwdGenerator.getPassword(mfaEmailOTPConfiguration.otpSize(),_KEYS);
}

This change configures the OTP generator to use only numeric characters.

Additional Information

did-this-article-resolve-your-issue

legacy-knowledge-base