Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

I would overwrite the postReset function inside the PasswordController since I guess your're using the trait ResetsPasswords.

	public function postReset(Request $request)
	{
		$this->validate($request, [
			'token' => 'required',
			'email' => 'required|email',
			'password' => 'required|confirmed',
		]);

		$credentials = $request->only(
			'email', 'password', 'password_confirmation', 'token'
		);

		$response = $this->passwords->reset($credentials, function($user, $password)
		{
			$user->password = bcrypt($password);

			$user->save();

            $token = \JWTAuth::fromUser($user);
            return \Response::json(compact('token'));
		});

		switch ($response)
		{
			case PasswordBroker::PASSWORD_RESET:
				return redirect($this->redirectPath());

			default:
				return redirect()->back()
							->withInput($request->only('email'))
							->withErrors(['email' => trans($response)]);
		}
	}
Last updated 9 years ago.
0

I'm confused about this part: return \Response::json(compact('token')); Are you going to return the token to the front end application? Why not let Laravel to send an email?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

mckibbe mckibbe Joined 3 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.