Welcome Guest, Not a member yet? Register   Sign In
Single use URL's?
#1

[eluser]DephNet[Paul][/eluser]
Hi Guys,

I am creating a web app that will take a users email address and add it to a database, now I know how infuriating it is to have someone add my email address to a random site, so I want to implement a single use URL, something like http://site.tld/verify/email/yepHedRafatRuYaj, as part of a double opt-in process.

The process I want to have is as follows:
1) Someone inputs their email address into the site.
2) The application checks to see if the email is actually an email. [working]
3) The application generates a single use URL.
4) The application emails the user a confirmation email, including the single use URL.
5) The user clicks the URL
6) The email is added to the database

Is CI able to cope with single use URLS? If not, what is the best way to go around getting a double opt-in for email addresses using CI?

Many Thanks
--Paul
#2

[eluser]Dahak-II[/eluser]
I don't see why not.

What I've done in the past is have the new user account added, but not flagged as 'validated' (only 'validated' accounts are granted access). At the time of account creation, I build a random string - as you are doing - and add it to the account record.

When the user clicks on the 'verify/email/uniquestring/' link, the controller function simply looks for the record with the matching 'uniquestring', marks the user record as validated and clears the validation string field.

If the 'uniquestring' doesn't exist in the user database, throw out an error message.

If you do something like that, I'd recommend checking to see if the randomly-generated string already exists in the user database, in the unlikely event that it matches a currently un-validated users' validation string (if found, generate a new one).
#3

[eluser]DephNet[Paul][/eluser]
Hi Dahak-II,

That is the way I was going to do it, I just wanted to confirm that that is the best way to do this.

Thanks for your help
--Paul
#4

[eluser]Dahak-II[/eluser]
[quote author="DephNet[Paul]" date="1299467253"]Hi Dahak-II,

That is the way I was going to do it, I just wanted to confirm that that is the best way to do this.

Thanks for your help
--Paul[/quote]

I can't say it's the best way, but the basic concept is sound enough.




Theme © iAndrew 2016 - Forum software by © MyBB