Salesforce Login Page: Custom login page with Visualforce and Apex for Salesforce Communities
4:39 PM
This article is a simple explanation of the use of the Site.Login()
Apex method. The documentation in detail from Salesforce is here http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm.
STEP 1:
Enable Communities by going to the below path, Your Name -> Setup -> App Setup -> Customize -> Communities -> Settings
STEP 2:
Create a new Community as shown below
STEP 3:
Create a Apex Class as shown below
Note: Replace 'null' with the URL to be redirected to after login.
STEP 4:
Create a Visualforce page 'CustomLoginPage' as shown below
STEP 5:
Navigate to Manage Communities from the setup menu, and click the 'Force.com' link as below
STEP 6:
Make the following changes as shown below.
STEP 7:
Modify the Apex Class 'CommunitiesLoginController' as below
STEP 8:
Modify the Visualforce page 'CommunitiesLogin' as below
STEP 9:
Make sure you publish the community. Navigate to the URL and you should see the custom login page as below.
STEP 1:
Enable Communities by going to the below path, Your Name -> Setup -> App Setup -> Customize -> Communities -> Settings
STEP 2:
Create a new Community as shown below
STEP 3:
Create a Apex Class as shown below
Note: Replace 'null' with the URL to be redirected to after login.
STEP 4:
Create a Visualforce page 'CustomLoginPage' as shown below
STEP 5:
Navigate to Manage Communities from the setup menu, and click the 'Force.com' link as below
STEP 6:
Make the following changes as shown below.
STEP 7:
Modify the Apex Class 'CommunitiesLoginController' as below
STEP 8:
Modify the Visualforce page 'CommunitiesLogin' as below
STEP 9:
Make sure you publish the community. Navigate to the URL and you should see the custom login page as below.
13 comments
Very Sleek explanation...Thanks for the post :)
ReplyDeleteThank you.
ReplyDeleteThis login will authenticate with what data?
ReplyDeleteI did as you wrote, and is not working...
ReplyDeleteCool article, Questions tho, are you only redirecting the user to your page when they get to the standard login page? Couldn't this be achieved by just changing settings through the UI?
ReplyDeletei tried the above code, but the user is been redirected to same page instead of redirecting to start url or community landing page. Did anyone try this?
ReplyDeleteYeah I get an infinite loop of login pages too
DeleteNot Working for me as well.
Deletei want to users to redirect to custom URL after login. how to do that?
ReplyDeleteThank you so much for the post very clear steps.
ReplyDeleteThanks for this code.
ReplyDeleteI am facing some difficulties while creating the test class for "customlogincontroller".
Please share the test class for the same.
Thanks for this code.
ReplyDeleteI am facing some difficulties while creating the test class for "customlogincontroller".
Please share the test class for the same.
thank u so much
ReplyDelete