Newer Version Available
Create a Custom Login Flow with Visualforce
Define the business process in an Apex controller of the Visualforce page. Salesforce doesn’t pass input variables to a Visualforce Page login flow, but you have access to user and login context. You must include one of these Apex methods.
- Auth.SessionManagement.finishLoginFlow() indicates that the login flow is done and redirects the user to the home page
- Auth.SessionManagement.finishLoginFlow(startURL) indicates that the login flow is done and redirects the user to a specific page.
The login flow runs in a restricted session. Calling a finishLoginFlow method removes the session restriction and gives users access to Salesforce or their community. You decide when or under what condition to call the method to remove the session restriction.
Here’s an example of a Visualforce Page login flow. The user clicks a button to invoke the finishLoginFlow method. Specify showHeader=”false” for the login flow to work correctly.
Here’s an example of an Apex controller that defines the business process.
Give each profile that you want to associate with this Visualforce Page access.
- From Setup, enter Visualforce in the Quick Find box, then select Visualforce Page.
- Next to the Visualforce page that you want to use, click Security.
- From the list of available profiles, add the profiles that you want to associate with this login flow.
- From Setup, designate the Visualforce page as a login flow, and connect the profiles to it. See Set Up a Login Flow and Connect to Profiles.