I have a community page with angular js implemented. It is a SPA as expected.

Angular calls the apex remote action methods receives a response and does some UI stuff.

First page(main page) is publicly accessible for the guest users and they are assigned to the guest profile.

On the main page, guest users can search for a product and add any product to the cart, however, before adding the product to the cart I need to display a login page popup window and give the ability to log in the community without reloading/refreshing the main page.

So that, as a result, I need to implement authorization on the community page without reloading/refreshing the page.

Please let me know if any more clarification needed.

Thanks in advance!

  • Is it possible to stash a state in localStorage, then pull that state back after the login reload?
    – dsharrison
    Jan 17, 2017 at 17:42
  • Hi D.S. Could you please elaborate your question? Jan 18, 2017 at 0:17
  • I am assuming that the contents of your cart are stored client side when the guest adds products. If you were to reload the page you would lose everything that only exists on the client. Can you stash that info in localStorage (goo.gl/d4Mgct), then on app load check to see if you have your localStorage cache and restore it back into your angular scope if you do? This would allow you to undergo a full page refresh without data loss. VF Remoting calls need the session cookie that is set when Salesforce performs authentication so I am not sure if there is another way to get at that value.
    – dsharrison
    Jan 18, 2017 at 0:36
  • @D.S. Thank for the clarification, but unfortunately, this solution doesn't work. Jan 18, 2017 at 18:48

1 Answer 1


Below is the signature of Site.Login method


public static System.PageReference login(String username, String password, String startUrl)

Return type is page reference. This will cause page to re-load.

The only hope on this is to use Angular routes to kind of re-load part of a page (sub page inside main page which hosts angular controller) which contains the login functionality.

Personally i have not tried this but just worth a shot!

  • The issue is that I have to reload the main page in order to apply new session. Jan 18, 2017 at 18:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .