I have created a community and i have somewhat modified my community login page which on proper credentials should redirect me to community login page.
But i am not able to make my login work.I read something about site.login function and i tried to implement that but it doesn't work..i tried with simple authentication also and it also didn't help me.
It just that this is my first time on community..So hope u guys can help me here even if i m being silly.
Apex code :
global with sharing class CommunitiesLoginController {
Public string userName {get;set;}
public string passWord {get;set;}
global CommunitiesLoginController () {
}
// Code we will invoke on page load.
global PageReference forwardToAuthPage() {
/*String startUrl = System.currentPageReference().getParameters().get('startURL');
String displayType = System.currentPageReference().getParameters().get('display');
return Network.forwardToAuthPage(startUrl, displayType); */
return null;
// PageReference objPageReference = new PageReference('/CommunitiesLanding');
// return objPageReference;
}
public PageReference Login() {
PageReference PageRef=Site.login(username, password, null);
if(PageRef!=null)
{
system.debug('in if--->');
PageReference PortalLogin=page.CommunitiesLanding;
return PortalLogin;
}else
{
system.debug('not in if--->');
return null;
}
/*
if(Site.login(userName , passWord ,'') != null){
return Site.login(userName ,passWord , '/CommunitiesLanding');
}
else{
return Site.login(username, password, null);
}
if(username =='samir' && password == 'samir'){
PageReference objPageReference = new PageReference('/CommunitiesLanding');
return objPageReference ;
}
else {
PageReference objPageReference = new PageReference('/CommunitiesLanding');
return objPageReference ;
}*/
}
}
my vf page :
<apex:page id="loginPage" controller="CommunitiesLoginController" title="{!$Label.site.site_login}">
<apex:form >
<apex:panelGrid columns="5">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Login" action="{!Login}" style="width:90px" />
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel value="UserName"></apex:outputLabel>
<apex:inputText id="username" title="username" value="{!userName }"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Password"></apex:outputLabel>
<apex:inputText id="Password" title="Password" value="{!passWord }"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:panelGrid>
</apex:form>
</apex:page>
there is lot of commented code in controller, its because i was trying different things
Thanks in advance guys
if(Site.login(userName , passWord ,'') != null){ return Site.login(userName ,passWord , '/CommunitiesLanding'); } else{ return Site.login(username, password, null); }
all other shouldn't work.