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

If you create the controller (RESTful) with artisan command (the easiest way) :

php artisan auth:reminders-controller

You must create the routes with :

Route::controller('password', 'RemindersController');

And you use this controller.

Last updated 2 years ago.
0

Morning, thanks! Ok I did create it with that command and now that I look at the terminal output I see this:

$ php artisan auth:reminders-controller
Password reminders controller created successfully!
Route: Route::controller('password', 'RemindersController'); <<< I should have read this!

So I've added that to the routes and tested. I then received the error: Controller method not found After some googling it looks like I also need:

Route::get('password/reset/{token}', 'RemindersController@getReset');
Route::post('password/reset/{token}', 'RemindersController@postReset');

But still the same error. I'm missing something big an obvious here aren't I? Here's the automatically generated RemindersController that I've not edited at-all:

<?php

class RemindersController extends Controller {

	/**
	 * Display the password reminder view.
	 *
	 * @return Response
	 */
	public function getRemind()
	{
		return View::make('password.remind');
	}

	/**
	 * Handle a POST request to remind a user of their password.
	 *
	 * @return Response
	 */
	public function postRemind()
	{
		switch ($response = Password::remind(Input::only('email')))
		{
			case Password::INVALID_USER:
				return Redirect::back()->with('error', Lang::get($response));

			case Password::REMINDER_SENT:
				return Redirect::back()->with('status', Lang::get($response));
		}
	}

	/**
	 * Display the password reset view for the given token.
	 *
	 * @param  string  $token
	 * @return Response
	 */
	public function getReset($token = null)
	{
		if (is_null($token)) App::abort(404);

		return View::make('password.reset')->with('token', $token);
	}

	/**
	 * Handle a POST request to reset a user's password.
	 *
	 * @return Response
	 */
	public function postReset()
	{
		$credentials = Input::only(
			'email', 'password', 'password_confirmation', 'token'
		);

		$response = Password::reset($credentials, function($user, $password)
		{
			$user->password = Hash::make($password);

			$user->save();
		});

		switch ($response)
		{
			case Password::INVALID_PASSWORD:
			case Password::INVALID_TOKEN:
			case Password::INVALID_USER:
				return Redirect::back()->with('error', Lang::get($response));

			case Password::PASSWORD_RESET:
				return Redirect::to('/');
		}
	}

}

The docs imply to me that this controller is ready to roll, but do I need to make changes to it?

Thanks, Ben

Last updated 2 years ago.
0

Did you make those views ?

password.remind password.reset

Last updated 2 years ago.
0

was this solved? im having the same problem.. got a view with a form to submit an email:

<form action="{{ action('RemindersController@postRemind') }}" method="GET"> <input type="email" name="email"> <input type="submit" value="Send Reminder"> </form>

but when i click submit i get an httpnotfound exception

Last updated 2 years ago.
0
<form action="{{ action('RemindersController@postRemind') }}" method="GET">

Change method="GET" to POST or delete it.

Zsolt

0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.