You need to sign in to do that
Don't have an account?
Site.login(UN,PW,StartURL) returning PageReference Null.
Hi,
I am trying to access Customer portal through site,I have already done the required configuration on site and Customer portal level.Actual requirement is to access Site from external application using 'siteGuestuser' and then user should be redirected to customer Portal on corect page. when i am debugging and printing username,password and startURL, its getting printed correctly but site.login(UN,PW,StartURL) is returning null as page Reference e.g. UN:-abcd@gmail.com, PW:- Password@123 startURL:='/apex/programpage?proname=test program'. I am also encoding the startURL before passing it.Site domain is not having any prefix associated with it. Error is appearing like: Authentication failed: Authentication to Zone failed.
Apex code method are as below:-
String startUrl = Encodingutil.urlDecode(Apexpages.currentPage().getParameters().get('startURL'), 'UTF-8');
system.debug('=========Login Is enabled for Site==========='+Site.isLoginEnabled());
system.debug('=====Start URL========'+startUrl);
system.debug('=====Portal User Name========'+Username);
system.debug('=====Portal User Password========'+Password);
PageReference ref = Site.login(Username, Password, startUrl);
if(ref == null){
//Get the inaccesible url for the current site
SiteSettings__c setting = SiteSettings__c.getValues(Site.getName());
String url = setting == null ? null : setting.Inaccessible_url__c;
System.debug('***Site '+ Site.getName() +' inaccssessible for user '+ setting.Name);
ApexPages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Access denied!'));
return null;
}
When i am trying with same username ,password to access directly its getting through .
Guys please help me out.Thanks in advance
Regards
PK