• Cva
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi, my app flow for my site requires users to login inorder to access pages after a point.  However I do not want them to return to a specific URL, I would like the user to continue to the page they attempted to go to before login was prompted.

I attempted the code below, however it does not redirect from the authentication page although authentication is successful.  It appears that using currentPage() keeps me at a stand still.  Not sure if there is another method I can use?

 

Any one have any suggestions?

 

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

 

  • March 12, 2012
  • Like
  • 0

I have a form on a sites page that guest users fill out. However submitting form requires authentication, so I'm trying to figure out how to retain the user's submitted form data  through the authentication/registration process, and then post it.  The main goal is to allow the user to authenticate only when needed.

 

The flow would go something like this:

1. User goes to the form page.
2. User fills out the form and presses the Submit button.
3. If the user is not logged in, they are prompted to login or
register.
4. User logs in/registers using standard authentication
5. Once logged in/registered, the form data from Step 2 gets submitted and are redericted to a summary page of their submission

 

I'm not sure how to approach this.

A) I have had thoughts of adding the sitelogin and siteregister controller as extensions to my controller to see if that state gets stored, however concerned about a growing view state on my page.

B) I thougfht about cookies to store the form values, however concerned that cookies may be disabled by the user.  Another challenge is that my form is generated by dynamic visualforce components so the form questions and answers will be different for every session.

 

It seems like this is a problem that a lot people would have solved before.

Any pointers on a best practice for this?

  • March 11, 2012
  • Like
  • 0