I have a custom public site that leads customers to join a customer community. I want to embed the login page in my public site via iframe. However, the issue is that the iframe X-ORIGIN will not allow a different domain.

I've embedded visualforce page for login that uses a custom controller (below).

What I'm finding is that the custom login controller relies on a parent URL or Site Class to login the community. I'm thinking if I can set the site to one of my communities manually then I can authenticate and open up a new browser window into the community.

 global PageReference login() {
        Site s = new Site();
        //not sure what goes here to make this happen
        return s.login(username, password, '/vfAMCC_Redirect');        
  • Instead of creating a new site instance, you need to use return site.login(username,password, yourPageLink) Also refer to this for more info. salesforce.stackexchange.com/questions/49861/… – Richard N Jan 25 '17 at 0:40
  • That is how it's done when the login site is a part of the community page (same URL). If my community site is comun.force.com/communityName and then I have a page /login that return site will work. If I host the same visualforce page elsewhere it won't login to the community because the parent site is not comun.force.com/community. – tjcinnamon Jan 25 '17 at 1:08
  • You'd be violating security by attempting to log-in from anyplace that's not on a Salesforce domain unless you configure SSO. What you're attempting to do isn't going to pass muster and isn't supported by the platform. – crmprogdev Jan 25 '17 at 1:56
  • I figured because it was on a Salesforce Site (in my org) that it would be okay to do – tjcinnamon Jan 25 '17 at 2:12
  • @crmprogdev if it's a site off my Org is that possible? – tjcinnamon Jan 30 '17 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.