Reputation: 28843
Hi I'm looking to create a simple Forgot Password system using CakePHP where a user will type in their username/email and then receive an email with a link they can click to create a new password.
I've Googled around but not found anything :/
Using CakePHP 1.3
Upvotes: 3
Views: 7936
Reputation: 1437
reset_password
controller action.reset_password
controller action look for this->data['User']['email']
and store the email address in a database table.key
or token
field. This field should be CHAR(40). In the reset_password
action do $key = Security::hash(String::uuid(),'sha1',true)
to create a key or hash and store it in the key
or token
field.$url = Router::url( ($this->here), true ).'/'.$key
inside the controllers reset_password
action. This will generate a url based on the current action and append to it the key parameter which you can verify in this same function when the user clicks the email link.Email
component to actually send the e-mail including the generated URL above in the message body. This should be enough to get you going in the right direction.
Upvotes: 12
Reputation: 2483
You can take a look at two pre-made solutions that might suit your requirements:
Spark Plug by Jedt - https://github.com/jedt/spark_plug
Users Plugin by CakeDC - https://github.com/CakeDC/users
Both have a "Forgot your Password" functionality. You could either include one of the plugins into your project, thus getting the full benefit of all the code, or you could simply poach their code for how to make it work within your own project.
Upvotes: 2
Reputation: 490423
Upvotes: 3