0

I want to use laravel's reset password functionality to reset password for a logged in user (I'll use that instead of enabling users to change their password).

My problem is, when I redirect to the password reset route (/password/email/) and the user is logged in, they will be automatically redirected to the home logged in screen.

My first try then.. was to implement a method at the User model called sendResetPasswordLink. But, as I looked more into the platform I would need to generate the token and add to the password_resets table..

I looked into DatabaseTokenRepository and PasswordResetServiceProvider classes, looking for a function I could call to generate the token, but there is no function I could call statically..

I'm really lost, can someone point me the way?

2
  • Shouldn't reset password only happen when the user didn't have his password? Commented Sep 2, 2015 at 16:48
  • Sometimes he will be logged in without a password (social login) to keep it simple I'm just centering all cases in the reset password functionality Commented Sep 2, 2015 at 16:51

1 Answer 1

2

From the ResetsPasswords trait, the answer is:

Password::sendResetLink(['email' => Auth::user()->email], function (Illuminate\Mail\Message $message) {
    $message->subject('Your Password Reset Link');
});

You'll need to create your own route and controller method that allows this to be called for logged-in users.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.