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
DivyaReddyDivyaReddy 

very urgent issue on customer portal

How can i redirect to other visualforce page when the login credential is true.

 

Here i am posting my code :

 

global with sharing class SiteLoginController {
    global String username {get; set;}
    global String password {get; set;}

    global PageReference login() {
        String startUrl = System.currentPageReference().getParameters().get('startURL');
         return Site.login(username, password, startUrl);

        // return null;

       //return.page.Account;

        
    }

 

if return null is giving it is returing nothing as usally.

 

if return page.Account; is giving then it is redirecting with out validating login credential is true.

 

 

Can any one help on this issue.



spraetzspraetz

Perhaps something like:

 

global PageReference login() {
    String startUrl =System.currentPageReference().getParameters().get('startURL');
    PageReference pr = Site.login(username, password, startUrl);
    if(pr.getUrl().contains(startUrl)){
        return <<SOMEPLACE>>
    }
    else{
        return <<SOMEPLACE ELSE>>
    }
}

 

hemantgarghemantgarg

You can change the startURL to the relative url of page where you want to redirect after login to site , Try Following :-

 

global with sharing class SiteLoginController {
    global String username {get; set;}
    global String password {get; set;}

    global PageReference login() {
        String startUrl = System.currentPageReference().getParameters().get('startURL');

         startUrl = '/apex/<Name of Visualforce page>';
         return Site.login(username, password, startUrl);

       
    }