Two Factor Authentication for Magento 2 functionality is used to provide the extra security feature to the account. This is verified in two cases i.e creation of a new account and login into the account of existing customers. It is one the most reliable process of security of account purposes.
Features
- At the time of registration, Auth Code will be sent to the mobile number entered. However, it will be verified after the account will be created.
- Admin can enable/disable the TwoFactorAuth module from the admin configuration.
- Admin can enable/disable TwoFactorAuth verification of the customers at the time of registration
- Customers have to verify to access the account.
- Verification code expiration time period can be changed by the admin.
Installation
Customers will get a zip folder and they have to extract the contents of this zip folder on their system.
The extracted folder has an src folder, inside the src folder you have the app folder.
You need to transfer this app folder into the Magento2 root directory on the server as shown below.
After the successful installation, you have to run these commands in the Magento2 root directory:
First command –
php bin/magento setup:upgrade
Second Command –
php bin/magento setup:di:compile
Third Command –
php bin/magento setup:di:deploy
Installation using composer:
If the module is purchased from the official Magento Marketplace.
Add the extension’s name and version to your composer.json
file:
- Navigate to your Magento project directory and update your composer.json file.
composer require <composer name>:<version>
composer require webkul/2fa
- Enter your authentication keys. Your public key is your username; your private key is your password.
- Wait for Composer to finish updating your project dependencies. And make sure there aren’t any errors.
Verify the extension
Run the command to check the installation.
php bin/magento module:status Webkul_TwoFactorAuth
By default, the extension is probably disabled:
Module is disabled
The extension name is in the format <VendorName>_<ComponentName>
; This is a different format from the Composer’s name. Use this format to enable the extension. If you are unsure of the extension name, run:
php bin/magento module:status
and look for the extension under “List of disabled modules”.
Enable the extension
Some extensions won’t work properly.
For this clear Magento-generated static view files first.
–clear-static-content
1.Enable the extension and clear static view files:
php bin/magento module:enable Webkul_TwoFactorAuth --clear-static-content
2.Register the extension:
php bin/magento setup:upgrade
3.Recompile your Magento project: In Production mode, you may receive a message to “Please rerun Magento compile command”. Magento does not prompt you to run the compile command in Developer mode.
php bin/magento setup:di:compile
4.Verify extension is enabled:
php bin/magento module:status Webkul_TwoFactorAuth.
You will see output extension is no longer disable:
Module is enabled.
5. Clean the cache:
php bin/magento cache:clean.
6. Configure the extension in Admin as needed.
After running the commands, you have to flush the cache from the Magento admin panel. By navigating through System > Cache management as shown below.

Multi-Lingual Support
For multilingual support, the admin will navigate through Store > Configuration > General > Locale Options. Now select the locale as English (the language into which the admin wants to translate his store content).

Admin Configuration
Once the module of Two Factor Authentication for Magento 2 is installed completely. The admin will now manage the feature from the backend by navigating to Stores > Configuration > TwoFactorAuth.
The admin will set the Enable to Yes to make the module active for the store. Else, the admin will set No to disable the feature for the store.
Twilio Auth
“Twilio” is a communications platform for sending and receiving text messages using its web service APIs.
The admin can signup for the Twilio services and register to the Twilio. To register, the admin can visit Twilio then click on the signup button.
Now, from the Twilio account, the admin can access the information required in the admin dashboard.
New Customer:-Account Registration and verification
At time new account creation by customer. OTP will sent to customer mobile number. Now customer to go through the two-step verification. As per the given below image.
Enter the OTP sent on the registered mobile number. After the verification Account is verified successfully of a new customer. It appears like the given below image.
Existing Customer
TwoFactAuth is applicable for the existing customer. Any time an existing customer does the login. He receives the OTP. After entering the OTP they can use their account after verification.
The registered mobile will receive the OTP via SMS, as shown in the image below.
Admin Enable /Disable
In configuration settings, the admin can enable and disable the twofactAuth.
- Enable Module on Frontend:- Admin can enable and disable the model by YES/No
- Need Auth Validation On Customer Registration:- To register new customer validation needed or not YES/No.
- Auth Code Expiry:- OTP duration is between 60 to 300 sec.
That’s all for the Two Factor Authentication for Magento 2 . Still, if you face any issue feel free to add a ticket. Let us know your views to make the module better https://webkul.uvdesk.com/