laravel/framework — pull request #2705 by jcoetzee (2013-11-12 09:14:44+00:00)
Title: [Proposal] Change password reset to use the user id instead of email

This is a long shot but I think that storing the id of the user instead of the email address is a better way to handle password reset. This way when the token is created and stored, the id of the user is stored with it instead of the email. When the token is submitted the id of the user in question is returned and that user is updated. This saves having to pass in the email address of the user in question and therefore can be used without passing in any credentials.

Of course this can be also achieved while still using the email address but in the interests of efficient DB design ints are more efficient than varchars.

It simplifies calling `reset` from:

```php
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password'),
'password_confirmation' => Input::get('password_confirmation')
);

return Password::reset($credentials, function($user, $password)
{
$user->password = Hash::make($password);
$user->save();
return Redirect::to('home');
});
```

To:
```php
return Password::reset(function ($user, $password) {
$user->password = Hash::make($password);
$user->save();
return Redirect::to('login');
});
```

Of course the `auth:reminders` migration will have to be changed as well to use an int for the id instead of a varchar. I'm using the following table:
```SQL
CREATE TABLE `password_reminders` (
`id` int(10) unsigned NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
KEY `token` (`token`),
KEY `id` (`id`),
CONSTRAINT `password_reminders_ibfk_1` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
```