Alex
Alex

Reputation: 331

Laravel 4, reset password only with token (howto check it and get user)

What is the best way to reset password only with token?

Now it mades with token and email, I want to get an email by checking tocket in reminders table.

Thanks!

Update Resolved this by:

$email = DB::table(Config::get('auth.reminder.table'))->where('token', $token)->pluck('email');

Upvotes: 1

Views: 1847

Answers (1)

nitrammit
nitrammit

Reputation: 143

Here's how I do password resets.

  1. User clicks Forgot Password link and is taken to a form with one field for email.
  2. They enter their registered email address and I check the email exists in the DB. If it does, I store a random reset code for that user using Str::random(60). I then save the user and email them a link with a reset code (eg. http://domain.com/reset/CODE).
  3. User clicks the link and is taken to the URL above which checks the CODE. If the CODE exists in the DB, the password for the matching user is reset to something random using Str::random(10) and this new password is mailed to the user.

Not sure if this is right/wrong, but it works for me.

Upvotes: 2

Related Questions