How many times, you thought of having customized login experience for your Salesforce users?
Think about user login in the system for the first time, and we show a branded Welcome message OR ask for accepting the terms and condition agreement before start using Salesforce. Existing?
Well, entering just username and password to login to Salesforce is not enough sometimes. Thanks for login flow that can let you customize your login experience in Salesforce org. Login flow is used to customize the user login experience in the Salesforce. When the login flow is set up, the user can successfully log in with his credentials and the login flow appears. If login flow is successful as per the intended business goal, the user will be redirected to the org. If it fails, the user will be logged out.
Login flow can be used to customize the login experience and integrate business processes with Salesforce authentication.
Common use cases where login flow is applicable:
- Collecting and updating user data at login
- Configuring two-factor authentication
- Integrating third-party strong authentication methods.
Login flow can be of two types:
Visual Force page: We can create a custom login flow programmatically via visual force and apex controller which gives you a complete control over the look and feel and the behaviour of the flow.
Flow: We can create a login flow using the point-and-click Flow Builder.
Let’s say, you want to configure a login flow which asks the user to agree to the required terms and conditions before continuing into the org. Here we can opt for flow type login flow.
STEP 1: Create the flow that serves a purpose
This can have a start screen displaying terms of service with a checkbox for acceptance. If the user accepts, he should be redirected to the org. Otherwise, it should stay on the screen terms screen.
Prepare a start screen like this:
Use a decision element to check if the accept checkbox is set or not. Set two outcomes for “accepted” or “not accepted” conditions:
Connect the start screen to this decision element and the decision element’s “not accepted” outcome back to the start screen that builds a two-way connection between the elements. The final flow might look like this:
We have not explained flow creation in-depth here. Please check the Salesforce documentation for the same.
STEP 2: Create a login flow for using the above flow and associate it to a test profile.
Go to Setup > Login Flow > Click “New” and create a flow with the below inputs.
Remember- You can associate login flow with one profile only. The flow will be launched to all users under the selected profile. Feel free to clone the existing flow for different profiles.
IMPORTANT: WE DO NOT RECOMMEND SETTING UP LOGIN FLOW FOR ADMIN USERS – IF YOUR FLOW FAILS, YOU WILL NEVER BE ABLE TO LOGIN.
STEP 3: Login as test profile user and test the flow
Login with test user credential:
On successful login, it takes you to the login flow.
When you click the “accept” checkbox and the “Next” button, you will be redirected to the org successfully. If you didn’t click on the accept button but clicked on “Next”, it will display the same screen again.
STEP 4: Update the login flow to set the profile to the intended profile
Once you are sure about the flow functionality, update the login flow’s profile to an actual business profile.
Check out how you can customize user authentication with Login Flows, Click.