Reputation: 7022
I want to make some custom routes for password resets, here's what i've done so far:
First, i created my own routes
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
Route::get('/olvide-mi-contrasena', [
'as' => 'clubOlvide',
'uses' => 'Auth\PasswordController@getEmail'
]);
Route::post('/olvide-mi-contrasena', [
'as' => 'clubPostOlvide',
'uses' => 'Auth\PasswordController@postEmail'
]);
Route::get('/restablecer-contrasena/{token}', [
'as' => 'clubRestablecer',
'uses' => 'Auth\PasswordController@getReset'
]);
Route::post('/restablecer-contrasena/{token}', [
'as' => 'clubPostRestablecer',
'uses' => 'Auth\PasswordController@postReset'
]);
Second, i overrided the ResetsPasswords trait at PasswordController
private $redirectTo = '/ingresar';
public function getEmail()
{
return view('Club.auth.password');
}
public function getReset($token = null)
{
if (is_null($token))
{
throw new NotFoundHttpException;
}
return view('Club.auth.reset')->with('token', $token);
}
Third, change the action at the view
<form class="form-horizontal" role="form" method="POST" action="{{ route('clubPostRestablecer',['token' => $token]) }}">
Fourth, i edited the mail configuration
return [
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => ['address' => '[email protected]', 'name' => 'Support'],
'encryption' => 'tls',
'username' => '[email protected]',
'password' => 'googlePassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
And i tested it... It send the reset link, and the link works, it resets the password, but it's using the default route, i want it to send the custom route, here's what i'm saying:
Email received (i'll replace the real token with word token in the link to make the post more readable):
Click here to reset your password:
What i want it to be:
Click here to reset your password:
If i copy the token sent to password/reset/token
and paste it restablecer-contrasena/token
it works, so i would like to know how to change the link sent to the email?
Upvotes: 1
Views: 1600
Reputation: 7022
Got it!, The password reset email uses a template, configured in config/auth.php See:
When a user submits a request to reset their password, they will receive an e-mail with a link that points to the getReset method (typically routed at /password/reset) of the PasswordController. You will need to create a view for this e-mail at resources/views/emails/password.blade.php. The view will receive the $token variable which contains the password reset token to match the user to the password reset request. Here is an example e-mail view to get you started:
<!-- resources/views/emails/password.blade.php -->
Click here to reset your password: {{ route('clubPostRestablecer',['token' => $token]) }}
Upvotes: 0