#124: Updated the change e-mail confirmation to be a notification

This commit is contained in:
Andy Heathershaw 2019-07-14 14:35:26 +01:00
parent 4af68cd055
commit e794f99ead
3 changed files with 42 additions and 8 deletions

View File

@ -2,20 +2,17 @@
namespace App\Http\Controllers\Gallery;
use App\Album;
use App\Facade\Theme;
use App\Facade\UserConfig;
use App\Helpers\DbHelper;
use App\Http\Controllers\Controller;
use App\Http\Requests\SaveUserSettingsRequest;
use App\Mail\UserChangeEmailRequired;
use App\Notifications\UserChangeEmailRequired;
use App\User;
use App\UserActivity;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Symfony\Component\HttpFoundation\Request;
class UserController extends Controller
@ -528,7 +525,7 @@ class UserController extends Controller
$oldEmailAddress = $user->email;
$user->email = $newEmailAddress;
Mail::to($user)->send(new UserChangeEmailRequired($user));
$user->notify(new UserChangeEmailRequired());
$user->email = $oldEmailAddress;
}
}

View File

@ -6,11 +6,9 @@ use App\Facade\Theme;
use App\Facade\UserConfig;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class UserChangeEmailRequired extends Mailable
class UserChangeEmailRequired extends MailableBase
{
use Queueable, SerializesModels;

View File

@ -0,0 +1,39 @@
<?php
namespace App\Notifications;
use App\Mail\MailableBase;
use App\Mail\UserChangeEmailRequired as UserChangeEmailRequiredMailable;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class UserChangeEmailRequired extends Notification
{
use Queueable;
use DatabaseEmailNotification;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
*/
public function toMail($notifiable)
{
$mailable = new UserChangeEmailRequiredMailable($notifiable);
$this->setPropertiesOnMailable($mailable, $notifiable);
return $mailable;
}
}