function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Btuitasi1Btuitasi1 

Custom Community Login

I've created a custom login page for my customer community login members. Here is my controller for the login page:
/**
 * An apex page controller that exposes the site login functionality
 */
global with sharing class CustomLoginController {
    global String username{get;set;}
    global String password{get;set;}
    global CustomLoginController () {}
    global PageReference forwardToCustomAuthPage() {
        return new PageReference( '/CostCenterLogin');
    }
    global PageReference login() {
        return Site.login(username, password, null);
    }

}

Here is the controller for my landing page:
public with sharing class topIdeaExt {
           
    public List<Idea> getRecent2()
    {
        return [SELECT Id, Title, Name__c, CreatedDate, Voting_Status__c FROM Idea order by createdDate desc Limit 2];
    }
    public List<Idea> getMostVoted2()
    {
        return [SELECT Id, Title, Name__c, CreatedDate, Voting_Status__c FROM Idea order by VoteTotal desc, CreatedDate desc Limit 2];
    }
    public List<AggregateResult> getTop6Contributors()
    {
        return [SELECT CreatedById, CreatedBy.Name Name  FROM Idea group by createdbyid, CreatedBy.Name order by count(CreatedById) desc limit 6];
    }
    
     // Code we will invoke on page load.
    public PageReference forwardToCustomAuthPage() {
        if(UserInfo.getUserType() == 'Guest'){
            return new PageReference('/CostCenterLogin');
        }
        else{
            return null;
        }
    }

    public topIdeaExt() {}
}

I've set up the login and landing pages in my communities setup and added customer community login user profile to my settings already. When I go to login as a test user, it seems to load, but it doesn't take me to the landing page.

Any ideas on how to fix this issue? I've been using this as a reference: 
http://appirio.com/category/tech-blog/2013/10/create-custom-salesforce-communities-login-landing-page/

Thanks!
Best Answer chosen by Btuitasi1
Tushar sharmaTushar sharma
return Site.login(username, password, null);

in the place of null give the PageReference of your Home Page if you give null then it redirect to landing page which might be login page also give access to those page to your community user .

All Answers

Tushar sharmaTushar sharma
return Site.login(username, password, null);

in the place of null give the PageReference of your Home Page if you give null then it redirect to landing page which might be login page also give access to those page to your community user .
This was selected as the best answer
Btuitasi1Btuitasi1
That fixed the issue. Thank you!
Fawad Ahmed 19Fawad Ahmed 19
how we can get the home page URL.?