Legacy Knowledge Base
Published 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

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

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