Verify user notification (#3474)

This commit is contained in:
David Bomba 2020-03-11 10:40:10 +11:00 committed by GitHub
parent 70a560c474
commit b2033a54f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 20 deletions

View File

@ -27,11 +27,10 @@ trait VerifiesUserEmail
* @param $code
* @return \Illuminate\Http\RedirectResponse
*/
public function confirm($code)
public function confirm()
{
//$user = User::where('confirmation_code', $code)->first();
if ($user = User::whereRaw("BINARY `confirmation_code`= ?", $code)->first()) {
if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->route('confirmation_code'))->first()) {
$user->email_verified_at = now();
$user->confirmation_code = null;
$user->save();

View File

@ -75,7 +75,7 @@ class CreateUser
//'settings' => DefaultSettings::userSettings(),
'settings' => null,
]);
event(new UserWasCreated($user, $this->company));
return $user;

View File

@ -12,7 +12,7 @@
namespace App\Listeners;
use App\Libraries\MultiDB;
use App\Mail\VerifyUser;
use App\Notifications\Ninja\VerifyUser;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Queue\ShouldQueue;
@ -42,14 +42,11 @@ class SendVerificationNotification implements ShouldQueue
* @return void
*/
public function handle($event)
{//todo handle the change of DB locaiton to Company Token table
/*send confirmation email using $event->user*/
{
MultiDB::setDB($event->company->db);
Mail::to($event->user->email)
//->cc('')
//->bcc('')
->queue(new VerifyUser($event->user));
$event->user->notify(new VerifyUser($event->user));
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Notifications\Ninja;
use App\Mail\Signup\NewSignup;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
class VerifyUser extends Notification implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new notification instance.
*
* @return void
*/
protected $user;
public function __construct($user)
{
$this->user = $user;
}
/**
* 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)
{
$data = [
'title' => ctrans('texts.confirmation_subject'),
'message' => ctrans('texts.confirmation_message'),
'url' => url("/user/confirm/{$this->user->confirmation_code}"),
'button' => ctrans('texts.button_confirmation_message'),
'signature' => '',
'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png',
];
return (new MailMessage)
->subject(ctrans('texts.confirmation_subject'))
->markdown('email.admin.generic', $data);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toSlack($notifiable)
{
}
}

View File

@ -19,7 +19,6 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => '', 'as' => ''], functi
/*Invitation catches*/
Route::get('{entity}/{invitation_key}/download', 'ClientPortal\InvitationController@routerForDownload');
Route::get('invoice/{invitation_key}/download_pdf', 'InvoiceController@downloadPdf')->name('invoice.download_pdf');
Route::get('quote/{invitation_key}/download_pdf', 'QuoteController@downloadPdf')->name('quote.download_pdf');
Route::get('credit/{invitation_key}/download_pdf', 'CreditController@downloadPdf')->name('credit.download_pdf');
@ -34,10 +33,10 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => '', 'as' => ''], functi
* Password Reset Routes...
*/
// Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
// Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
// Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
// Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
/*
* Social authentication
@ -100,11 +99,11 @@ Route::group(['middleware' => ['auth:user', 'web_db']], function () {
/*
* Inbound routes requiring DB Lookup
*/
// Route::group(['middleware' => ['url_db']], function () {
Route::group(['middleware' => ['url_db']], function () {
// Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
// });
});