diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index edb558f60104..0d6250f0d86b 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -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(); diff --git a/app/Jobs/User/CreateUser.php b/app/Jobs/User/CreateUser.php index 32e516ed43d8..c80fb673b873 100644 --- a/app/Jobs/User/CreateUser.php +++ b/app/Jobs/User/CreateUser.php @@ -75,7 +75,7 @@ class CreateUser //'settings' => DefaultSettings::userSettings(), 'settings' => null, ]); - + event(new UserWasCreated($user, $this->company)); return $user; diff --git a/app/Listeners/SendVerificationNotification.php b/app/Listeners/SendVerificationNotification.php index 65396b465bdd..0a360b1841dd 100644 --- a/app/Listeners/SendVerificationNotification.php +++ b/app/Listeners/SendVerificationNotification.php @@ -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)); + } } diff --git a/app/Notifications/Ninja/VerifyUser.php b/app/Notifications/Ninja/VerifyUser.php new file mode 100644 index 000000000000..9623c8d39198 --- /dev/null +++ b/app/Notifications/Ninja/VerifyUser.php @@ -0,0 +1,86 @@ +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) + { + + } +} diff --git a/routes/web.php b/routes/web.php index 798ba53563bc..8850bde4cac1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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'); -// }); +});