Newer Version Available
Create a Login Flow
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, and Developer Editions |
| User Permissions Needed | |
|---|---|
| To open, edit, or create a flow in the Cloud Flow Designer: | Manage Force.com Flow |
For example, you can insert a form to gather more information from users when they log in. You can direct them to pages for other information, like terms of services. A common use for a login flow is to implement a custom two-factor authentication (2FA) process for increased security.
You create login flow screens with the Cloud Flow Designer. Then you embed the screens in the standard Salesforce login page from Setup. During the authentication process, the user is directed to the login flow screens. When users successfully authenticate and complete the login flow, they’re redirected to Salesforce. The login process can also log out users immediately if necessary.
- Direct the user to log in with additional credentials, such as a time-based one-time password (TOTP)
- Force the user to log out
- Direct the user to a page with more options
Build Your Own Login Flow
Use the following process to build your own login flow.
- Create a flow using the Cloud Flow Designer and Apex.For example, you can design a custom IP-based 2FA flow that requires a second factor of authentication only if the user is logging in from outside of the trusted IP range.
Include the following in a flow.
- A new Apex class for defining an Apex plug-in. The plug-in implements from Process.Plugin and uses the Auth.SessionManagement class to access the time-based one-time password (TOTP) methods and services. The Apex class for the plug-in generates a time-based key with a quick response (QR) code to validate the TOTP provided by the user against the TOTP generated by Salesforce.
- A screen element to scan a QR code.
- A decision element to handle when the token is valid and invalid.

Use these input variables to populate the flow at startup.
Name Value Description LoginFlow_LoginType Type of login, such as Application, OAuth, or SAML LoginFlow_IpAddress User’s current IP address LoginFlow_LoginIpAddress User’s IP address used during login, which can change after authentication LoginFlow_UserAgent User agent string provided by the user’s browser LoginFlow_Platform User’s operating system LoginFlow_Application Application used to request authentication LoginFlow_Community Current community if this login flow applies to a community LoginFlow_SessionLevel Current session security level, which can be STANDARD or HIGH_ASSURANCE LoginFlow_UserId User’s 18-character ID Use these variables to specify where the user goes after completing the flow.Name Description LoginFlow_FinishLocation String. Specify where in the org the user goes after completing the login flow. The string must be a relative path or a valid Salesforce URL. The login process can’t redirect the user outside the org. LoginFlow_ForceLogout Boolean. Set this variable to true to log the user out immediately and force the user to exit the login flow. - Save the flow.
- Activate the flow.
- From the Login Flows Setup page, designate the flow as a login flow and connect it to profiles.