Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a custom page Create ticket and I want to host it on Sites. I am using partner credentials to log into sites. Once I enter partner credentials, it's always logging in with Guest User. How would I access the partner user in my Controller? We are displaying the related contacts/accounts based on login partner user on sites.

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

    global PageReference login() {       
        pageReference ticketing = new pageReference('/apex/TETicketing');
        pagereference TETicketing = Site.login(username, password, '/TETicketing');
        if(TETicketing != null ){ 
            ticketing.setRedirect(true);
            return ticketing;
        }        
        else  
            return site.login(username, password, null);

    }
}

Leveraged standard sitelogin page, modified cls

public PageReference login() {
    PageReference portalPage = new PageReference('/apex/ticketVFpage');
    portalPage.setRedirect(true);
    PageReference vResult = Site.login(username, password, '/ticketVFpage');
    if (vResult == null){ 
        return Site.login(username, password, null);
    } else { 
        return portalPage;
        //If authentication is successfull return to ticketVFpage page(ticketVFpage).        
    } 
}

This is how we are authenticating users using partner portal credentials. After login instead of getting the logged in user info we are getting guest user info.

share|improve this question
    
vipul any approach you are following?Like custom code ?Can you get us your code that i can debug that for you? –  Mohith Shrivastava Feb 25 '13 at 8:13
    
Is the visualforce page you are on accesibly by the guest profile, but not the partner profile by any chance ? –  Samuel De Rycke Feb 25 '13 at 9:34
    
I've moved the code that Vipul posted as comments into the question. Hopefully this makes the question clearer. –  metadaddy Feb 25 '13 at 19:39
    
Did you associate the portal with the site? –  metadaddy Feb 25 '13 at 19:41

2 Answers 2

up vote 8 down vote accepted

Anonymous (unauthenticated) users always show as "logged in" as the Guest User; authenticated website users always show as the actual authenticated user. If you are only seeing activity from the Guest User, you are not authenticating correctly, or you have not properly set up your Sites instance to accept logins via a portal user.

If you are doing it correctly, your portal user will be the context user in your controller. It is possible your problem page is only enabled for public access, not authenticated website, when you need it to be the opposite way around. An easy test is to open a new browser, clear cookies, then hit the page you need to be authenticated. If you see normal execution as the Guest User, instead of being redirected to a login or error page, your page security is misconfigured.

share|improve this answer
    
Yes,you are correct,when i access the page directly from site its not being redirected to a login or error page. –  Keepcalmncode Feb 25 '13 at 13:05

There is another possibility, assuming that the the Visualforce page is listed as one of the Site's Visualforce pages. If you are already authenticated, but you request the page over a non-secure connection (http) it will show up as the Site's Guest User.

You can see how this works pretty easily.

Authenticate and go to an https page.

https://mydeveloper-edition.na1.force.com/mysite/apex/myPage - User will be the authenticated user, assuming they are authenticated.

Then change the url to use http.

http://mydeveloper-edition.na1.force.com/mysite/apex/myPage - User will show up as the Site's Guest User, even though you were just authenticated. You can switch back and you'll see that you are still authenticated.

In production the URLs are more obvious, since you would likely be using a Custom Web Address for your site. The https requests would be made to https://yourDomain.secure.force.com/yourSite/myPage, whereas the http would be something like http://www.yourcustomwebaddress.com/myPage.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.