Welcome Guest, Not a member yet? Register   Sign In
Registration activation through email verification ation ation
#1

[eluser]jbads[/eluser]
Hi, Im sure some of you have dealt with activating a users registration by some kind of email verification system, where a user signs up and to make sure they give you a valid email address you auto send some kind of way for them to complete their registration.

Im trying to think of the most efficient way this can be achieved and thought i'd try get some ideas from the rest of you, and any resources you could point me to, to help keep me from going bald trying to impliment such a system.

Thanks heaps, Jake
#2

[eluser]crikey[/eluser]
Here's how I'm doing it (sorry, no code to share, just the logic):

I have two tables in the db, one for new (unactivated) users and one for users. Tables have the same structure except new users has an activation code field (my activation code is a random 9-character alpha numeric string).

When users sign up, generate the activation code and insert the record into new users table. Get the insert id. Load the email class. In the email message I include the url (something like www.yourdomain.com/users/activate/1234/xxxx). Where 'activate' is the method, 1234 is the insert id, and xxxx is the activation code.

The activate method takes $id and $code as parameters and makes a db query to match the id and the code in the new users table. If it is found, copy the row to the users table and delete from new users table.

That's pretty much it. There's obviously validation and stuff going on as well.

There's probably heaps of different ways of doing this, but that's how I do it.

Cheers!
#3

[eluser]nirbhab[/eluser]
http://www.4webby.com/freakauth/

Here a nice user management application built on CI.
As you guys are new to CI, it would be great help to you for a study.

Secondly, it contains email validation and activation module also
Have a nice day!
#4

[eluser]Synapse56[/eluser]
Hi

Here's a solution - this was done in Java for my employer so no code to offer but:

Create the user table with a UUID field (varchar) and a 'state' field.

Send the user an email with a hyperlink and the UUID embedded within it.

User clicks the URL within the email and it loads the browser (this can also be a manual copy & paste job too)

When the server PHP page receives the request, it updates the 'state' flag in the user table to active.

You could also run a cron job once a day to clear-down old, unactivated accounts.

It's pretty straight forward and easy to implement.

HTH
#5

[eluser]Sean Murphy[/eluser]
I did this just a week or two ago in CI. The approach I took is similar to the ones mentioned, but I ended up mimicking ExpressionEngine relatively closely.

I have one table for all users; activated and non-activated.

When a user registers, they are added to the user table, assigned the 'Pending' user group, and the 'verification_code' field is populated (md5($username.time())).

If one of the site admins wants to they can just assign the user to a different user group and they don't have to verify their email address.

But like I said, it's not much different from what's been outlined already.
#6

[eluser]megabyte[/eluser]
I came up with maybe an unusual way of doing this.

When a user wants to sign up, he enters his email and hits send. When he does this there is a table that only stores a the timestamp as an id and a random key (verification code). He gets emailed a link with the random key in the url and it checked to see if it exists against the table. Thats the only way you can get to the registration page is if you validate against that table.

This way you keep the table very small by deleting all records older than say 24 hours.

If you also want to have a forgotten password, then I'd suggest something like Sean Murphy suggested, I'm not sure my route would be easy to implement it and wold be adding more steps.




Theme © iAndrew 2016 - Forum software by © MyBB