Fixes for password reset via queues
This commit is contained in:
parent
0eb0d4739e
commit
b85aabe979
@ -19,7 +19,7 @@ BROADCAST_DRIVER=log
|
|||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=127.0.0.1
|
||||||
REDIS_PASSWORD=null
|
REDIS_PASSWORD=null
|
||||||
|
33
app/Notifications/ResetPassword.php
Normal file
33
app/Notifications/ResetPassword.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
|
||||||
|
class ResetPassword extends ResetPasswordNotification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail($notifiable)
|
||||||
|
{
|
||||||
|
if (static::$toMailCallback) {
|
||||||
|
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new MailMessage)
|
||||||
|
->markdown('email.user.passwordreset',[
|
||||||
|
'site'=>$notifiable->site,
|
||||||
|
'user'=>$notifiable,
|
||||||
|
'reset_link'=>route('password.reset',$this->token,true),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Notifications;
|
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Notifications\Notification;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
|
|
||||||
class ResetPasswordNotification extends Notification
|
|
||||||
{
|
|
||||||
use Queueable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The password reset token.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $token;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback that should be used to build the mail message.
|
|
||||||
*
|
|
||||||
* @var \Closure|null
|
|
||||||
*/
|
|
||||||
public static $toMailCallback;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a notification instance.
|
|
||||||
*
|
|
||||||
* @param string $token
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct($token)
|
|
||||||
{
|
|
||||||
$this->token = $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the notification's channels.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return array|string
|
|
||||||
*/
|
|
||||||
public function via($notifiable)
|
|
||||||
{
|
|
||||||
return ['mail'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the mail representation of the notification.
|
|
||||||
*
|
|
||||||
* @param mixed $notifiable
|
|
||||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
||||||
*/
|
|
||||||
public function toMail($notifiable)
|
|
||||||
{
|
|
||||||
if (static::$toMailCallback) {
|
|
||||||
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new MailMessage)
|
|
||||||
->markdown('email.user.passwordreset',[
|
|
||||||
'site'=>config('SITE_SETUP'),
|
|
||||||
'user'=>$notifiable,
|
|
||||||
'reset_link'=>route('password.reset',$this->token,true),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a callback that should be used when building the notification mail message.
|
|
||||||
*
|
|
||||||
* @param \Closure $callback
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function toMailUsing($callback)
|
|
||||||
{
|
|
||||||
static::$toMailCallback = $callback;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ use Laravel\Passport\HasApiTokens;
|
|||||||
|
|
||||||
use Leenooks\Carbon;
|
use Leenooks\Carbon;
|
||||||
use Leenooks\Traits\UserSwitch;
|
use Leenooks\Traits\UserSwitch;
|
||||||
use App\Notifications\ResetPasswordNotification;
|
use App\Notifications\ResetPassword as ResetPasswordNotification;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
use Spinen\QuickBooks\HasQuickBooksToken;
|
use Spinen\QuickBooks\HasQuickBooksToken;
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
public function sendPasswordResetNotification($token)
|
public function sendPasswordResetNotification($token)
|
||||||
{
|
{
|
||||||
$this->notify(new ResetPasswordNotification($token));
|
$this->notify((new ResetPasswordNotification($token))->onQueue('high'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Scopes **/
|
/** Scopes **/
|
||||||
|
@ -132,6 +132,6 @@ return [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'log_channel' => env('MAIL_LOG_CHANNEL'),
|
'log_channel' => env('MAIL_LOG_CHANNEL'),
|
||||||
'local_domain' => env('MAIL_HOST'),
|
'local_domain' => env('HOSTNAME'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
"laravel-mix": "^5.0.1",
|
"laravel-mix": "^5.0.1",
|
||||||
"resolve-url-loader": "^2.3.1",
|
"resolve-url-loader": "^2.3.1",
|
||||||
"sass": "^1.15.2",
|
"sass": "^1.15.2",
|
||||||
"sass-loader": "^8.0.0",
|
"sass-loader": "^8.0.0"
|
||||||
"vue-template-compiler": "^2.6.11"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.19",
|
"axios": "^0.19",
|
||||||
|
Loading…
Reference in New Issue
Block a user