This project provides a workaround for setting up Two-Factor Authentication (2FA) for Salesforce Community users with Partner Community or Customer Community licenses.
This project uses Apex and a Visualforce page to generate a token, send an email containing the token, and validate the token after the user enters before logging in to an Experience Cloud site.
- Create/deploy the Apex Class and Visualforce Page
- Navigate to Setup > Flows > Login Flows, create a new flow, and provide the inputs (Visualforce Page, Community User License, and Community User Profile). a. You'll need to create a Login Flow for each applicable Profile.
- Login to the community, and the Token screen will appear. Upon successful validation of the token, the user will be navigated to the home page. The Generate button can be used to resend the token if needed.
- Ensure the Profile(s) have access to the Apex class, Visualforce page, and organization-wide email address.
Requires an Org Wide Email Address.
Update the orgWide
variable in PortalMFAController.cls
to the email address of the org-wide email you want to use to send the token emails.
Each login will count towards your org's single use email limit. Consider how many logins per day you might have to your Experience Cloud site(s) before utilizing this solution.
This project is licensed under the MIT License.
Author: Scott Jacobson
Date: 2024-04-19