From b85aabe979693fc086dcf77c01b5a32a2fa0c057 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 30 Jan 2020 21:39:25 +1100 Subject: [PATCH] Fixes for password reset via queues --- .env.example | 2 +- app/Notifications/ResetPassword.php | 33 ++++++++ .../ResetPasswordNotification.php | 80 ------------------- app/User.php | 4 +- config/mail.php | 2 +- package.json | 3 +- 6 files changed, 38 insertions(+), 86 deletions(-) create mode 100644 app/Notifications/ResetPassword.php delete mode 100644 app/Notifications/ResetPasswordNotification.php diff --git a/.env.example b/.env.example index 5d8a5f6..3b67103 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file SESSION_LIFETIME=120 -QUEUE_DRIVER=sync +QUEUE_CONNECTION=sync REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null diff --git a/app/Notifications/ResetPassword.php b/app/Notifications/ResetPassword.php new file mode 100644 index 0000000..6b4d8b6 --- /dev/null +++ b/app/Notifications/ResetPassword.php @@ -0,0 +1,33 @@ +token); + } + + return (new MailMessage) + ->markdown('email.user.passwordreset',[ + 'site'=>$notifiable->site, + 'user'=>$notifiable, + 'reset_link'=>route('password.reset',$this->token,true), + ]); + } +} \ No newline at end of file diff --git a/app/Notifications/ResetPasswordNotification.php b/app/Notifications/ResetPasswordNotification.php deleted file mode 100644 index 670209f..0000000 --- a/app/Notifications/ResetPasswordNotification.php +++ /dev/null @@ -1,80 +0,0 @@ -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; - } -} diff --git a/app/User.php b/app/User.php index da95d40..926513b 100644 --- a/app/User.php +++ b/app/User.php @@ -11,7 +11,7 @@ use Laravel\Passport\HasApiTokens; use Leenooks\Carbon; use Leenooks\Traits\UserSwitch; -use App\Notifications\ResetPasswordNotification; +use App\Notifications\ResetPassword as ResetPasswordNotification; use App\Models\Service; use Spinen\QuickBooks\HasQuickBooksToken; @@ -200,7 +200,7 @@ class User extends Authenticatable public function sendPasswordResetNotification($token) { - $this->notify(new ResetPasswordNotification($token)); + $this->notify((new ResetPasswordNotification($token))->onQueue('high')); } /** Scopes **/ diff --git a/config/mail.php b/config/mail.php index 0aa5ea1..43d4186 100644 --- a/config/mail.php +++ b/config/mail.php @@ -132,6 +132,6 @@ return [ */ 'log_channel' => env('MAIL_LOG_CHANNEL'), - 'local_domain' => env('MAIL_HOST'), + 'local_domain' => env('HOSTNAME'), ]; diff --git a/package.json b/package.json index 7b532bf..c86f3fb 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ "laravel-mix": "^5.0.1", "resolve-url-loader": "^2.3.1", "sass": "^1.15.2", - "sass-loader": "^8.0.0", - "vue-template-compiler": "^2.6.11" + "sass-loader": "^8.0.0" }, "dependencies": { "axios": "^0.19",