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
chaitanya Deloitchaitanya Deloit 

Communities Home Page

Hi Team,

I developed a login page for my commuinity and i am giving another vf as Home Page.. And sharing the communtiy link to partner users for logginig in,
When the user clicks on the link its directly landing the home page instead of login page...

KIndly help me on this
Prem Anandh 1Prem Anandh 1
Hi Chaitanya,

We have to explicity give the security through code. Please refer my below code. 

Here I have activated my VF page as community home page and I have written a code if the user is logged into community then Userinfo.getUserType() should be "CspLitePortal" or "PowerCustomerSuccess" else it should be (not logged in) Guest based on this we can redirect to SignIn or Home page. 

Visualforce
 
<apex:page controller="CommunityHomeController" action="{!redirectUnAuthenticatedUser}">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
</apex:page>

Apex Class
 
public  without sharing class CommunityHomeController {
    
    public CommunityHomeController()
    {
        
    }
    
    //Checking for security
    public Pagereference redirectUnAuthenticatedUser()
    {
        if(Userinfo.getUserType() != 'CspLitePortal'  && Userinfo.getUserType() != 'PowerCustomerSuccess')
        {
            return new Pagereference('/login');
        }
        
        return null;
    }

}

Please let me if it's help you.

Thanks,
Prem Anandh