Fixes the forgotten password link
This commit is contained in:
Jeremy Quinton 2018-10-02 17:29:57 +02:00
parent ea53c20e76
commit 4e15d1e85d
6 changed files with 85 additions and 5 deletions

View File

@ -59,9 +59,7 @@ class RemindersController extends Controller
{
$this->validate($request, ['email' => 'required']);
$response = $this->passwords->sendResetLink($request->only('email'), function ($m) {
$m->subject($this->getEmailSubject());
});
$response = $this->passwords->sendResetLink($request->only('email'));
switch ($response) {
case PasswordBroker::RESET_LINK_SENT:

View File

@ -82,6 +82,7 @@ Route::group(
'as' => 'showResetPassword',
'uses' => 'RemindersController@getReset',
]);
])->name('password.reset');
Route::post('login/reset-password', [
'as' => 'postResetPassword',

View File

@ -2,16 +2,18 @@
namespace App\Models;
use App\Notifications\UserResetPassword;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword, SoftDeletes;
use Authenticatable, CanResetPassword, SoftDeletes, Notifiable;
/**
* The database table used by the model.
@ -155,4 +157,15 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
$user->api_token = str_random(60);
});
}
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new UserResetPassword($token));
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class UserResetPassword extends Notification
{
use Queueable;
private $token;
/**
* UserResetPassword constructor.
* @param $token
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$mailMessage = new MailMessage();
$mailMessage->view('Emails.Auth.Reminder', ['token' => $this->token]);
return ($mailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View File

@ -146,6 +146,7 @@ return [
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
/*
* Application Service Providers...
@ -206,6 +207,7 @@ return [
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,

View File

@ -3,7 +3,7 @@
@section('message_content')
<div>
Hello,<br><br>
To reset your password, complete this form: {{ route('showResetPassword', ['token' => $token]) }}.
To reset your password, complete this form: {{ route('password.reset', ['token' => $token]) }}.
<br><br><br>
Thank you,<br>
Team Attendize