This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm developing a social networking portal using spring framework.
I have the following requirement.
A user who is willing to join this social networking portal will fill up a online form and clicks 'Submit' button. Upon clicking submit button, i need to send an email to the email id provided during registration with a link to visit. Once user sees the email, he visits the link provided and then user account is created with data provided during registration.
Now my problem is i'm unable to come with some web link that i can provide in the email upon registration.
How to form a link with user data provided in a portlet?
Where should i keep that registration data (in session or ???)
I'm not clear on how to implement this logic. Can anybody give me insight on how to implement the above mentioned logic?
What you can do is have a table in the database that will hold the data the user entered in the form. So once the the user clicks the submit form, capture all the data in the table and use the generated key as an identifier.
Append the generated key as a request parameter (within the URL).. so when the user (at his/her own convenience) clicks on the link in the email, fetch all the previously stored data based on the id and proceed.
note: -- You can come up with an encrypting logic to encrypt the identifier so that no user will play around with it.
The approach is sound, but you absolutely, positively must encrypt the identifier. Or, even better, make it a hash of the ID and some lengthy "salt" string, which you then also store in the database. If the URL is then accessed you can extract that identifier and retrieve the record in the database that goes with it.
It's also common that the URL only has a limited validity (maybe 24 hours or so). After that, a new one must be generated.