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
seahorcesolnsseahorcesolns 

Site and Customer Portal - Under Construction Error

I'm using a Site as a custom login page for my customer portal.  I'm able to login and redirect the user to the /home/home.jsp page to get to the customer portal home page, but I'm getting the error message page instead of my custom home page (VF page).  It says "https://mycompany.secure.force.com/portal/ is under construction".  When I login via the portal URL, I don't get this error page.  I checked all of the class and VF page permissions for the portal profile.

 

Any ideas what could be wrong?

Best Answer chosen by Admin (Salesforce Developers) 
seahorcesolnsseahorcesolns

I was able to resolve this by using the startUrl = my portal URL.

 

example: 

 

global PageReference login() {
        String startUrl = System.currentPageReference().getParameters().get('startURL');
        PageReference PageRef=Site.login(username, password, startUrl);
        if(PageRef!=null)
        {
            PageReference PortalLogin=new PageReference('https://na8.salesforce.com/secur/login_portal.jsp?orgId=XXXXXXXXXXX&portalId=XXXXXXX&un='+username+'&pw='+password);
            return PortalLogin;
        }else
        {
            return PageRef;
        }
        
        
    }

 

 

All Answers

KapilCKapilC

HI

 

This url (/home/home.jsp) is for internal user and not for portal use. You should just redirect to your site address (which is defined in site base url) like abcd.efgh.na6.force.com or  abcd.efgh.na6.force.com/myhome (if your home page is myhome).

 

Thanks,

Kc

seahorcesolnsseahorcesolns

Thanks for your reply!  I tried that previously, but it would just refresh the page and show the "logout" link so I could tell that I was being logged in, but all I could see was the login screen.

 

Here's my code.  I would appreciate it if you could make suggestions on how to modify it.

 

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');
        //if (startUrl == null) startURL = (Site.getPrefix() == null ? '' : Site.getPrefix()) + '/home/home.jsp';
        startUrl = '/home/home.jsp';
        return Site.login(username, password, startUrl);
    }
    
     global SiteLoginController () {}
    
    @IsTest(SeeAllData=true) global static void testSiteLoginController () {
        // Instantiate a new controller with all parameters in the page
        SiteLoginController controller = new SiteLoginController ();
        controller.username = 'test@salesforce.com';
        controller.password = '123456'; 
                
        System.assertEquals(controller.login(),null);                           
    }    
}

 

BuntyBunty

Firtst don't use site.

Go tp your Org and try to login from your org not from site.

 

Your Login page will have some name. put it in the url  \apex\LoginPageName.

and try to debug the code. Some time it happens that there will be any exception but we are not able to because we are on site. 

From site any exception it will show same page.

 

I think your are using standard site login code ??? So there may be problem with credentials. Because for the customer portal username and Credentials are generated form the account object,

 

Please Check

Bunty 

seahorcesolnsseahorcesolns

I was able to resolve this by using the startUrl = my portal URL.

 

example: 

 

global PageReference login() {
        String startUrl = System.currentPageReference().getParameters().get('startURL');
        PageReference PageRef=Site.login(username, password, startUrl);
        if(PageRef!=null)
        {
            PageReference PortalLogin=new PageReference('https://na8.salesforce.com/secur/login_portal.jsp?orgId=XXXXXXXXXXX&portalId=XXXXXXX&un='+username+'&pw='+password);
            return PortalLogin;
        }else
        {
            return PageRef;
        }
        
        
    }

 

 

This was selected as the best answer