From 46e0a76fcb66aab99b280bc9d33f1bd48f19212c Mon Sep 17 00:00:00 2001 From: ilmedova Date: Wed, 7 Dec 2022 14:58:12 +0500 Subject: [PATCH 1/4] test mail reset --- app/Mail/ApplicationApproved.php | 33 -------------------------------- app/Mail/ApplicationRefined.php | 33 -------------------------------- app/Mail/ResetPassword.php | 3 +-- 3 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 app/Mail/ApplicationApproved.php delete mode 100644 app/Mail/ApplicationRefined.php diff --git a/app/Mail/ApplicationApproved.php b/app/Mail/ApplicationApproved.php deleted file mode 100644 index bf7399c6..00000000 --- a/app/Mail/ApplicationApproved.php +++ /dev/null @@ -1,33 +0,0 @@ -view('view.name'); - } -} diff --git a/app/Mail/ApplicationRefined.php b/app/Mail/ApplicationRefined.php deleted file mode 100644 index 55b738e2..00000000 --- a/app/Mail/ApplicationRefined.php +++ /dev/null @@ -1,33 +0,0 @@ -name = $name; - } - - /** - * Build the message. - * - * @return $this - */ - public function build() - { - $user['name'] = $this->name; - - return $this->subject('Your application has been refined!') - ->view('emails.notifications.application_refined', ['user' => $user]); - } -} diff --git a/app/Mail/ResetPassword.php b/app/Mail/ResetPassword.php index d8a84b86..31ca7558 100755 --- a/app/Mail/ResetPassword.php +++ b/app/Mail/ResetPassword.php @@ -36,7 +36,6 @@ public function build() $user['name'] = $this->name; $user['token'] = $this->token; - return $this->subject('Resetting your password') - ->view('emails.reset-password', ['user' => $user]); + return $this->view('emails.reset-password', ['user' => $user]); } } From fe49e48a31c04a1bf59c9187858b26b5befd85e2 Mon Sep 17 00:00:00 2001 From: ilmedova Date: Wed, 7 Dec 2022 15:07:43 +0500 Subject: [PATCH 2/4] test user notify reset password --- app/Http/Controllers/API/ClientController.php | 7 +- app/Mail/ResetPassword.php | 41 ------------ app/Notifications/PasswordReset.php | 66 +++++++++++++++++++ 3 files changed, 70 insertions(+), 44 deletions(-) delete mode 100755 app/Mail/ResetPassword.php create mode 100644 app/Notifications/PasswordReset.php diff --git a/app/Http/Controllers/API/ClientController.php b/app/Http/Controllers/API/ClientController.php index ceb2ea0d..60a265a7 100644 --- a/app/Http/Controllers/API/ClientController.php +++ b/app/Http/Controllers/API/ClientController.php @@ -8,7 +8,6 @@ use App\Http\Requests\API\ClientRequest; use App\Http\Resources\ClientResource; use App\Mail\EmailVerification; -use App\Mail\ResetPassword; use App\Models\Account; use App\Models\Client; use Illuminate\Http\Request; @@ -18,7 +17,7 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Lang; use App\Http\Controllers\Controller; - +use App\Notifications\PasswordReset; class ClientController extends Controller { @@ -156,7 +155,9 @@ public function sendPasswordResetLinkEmail(Request $request) { $token = rand(1000, 9999); - Mail::to($request->email)->queue(new ResetPassword($user->firstname, $token)); + $user->notify(new PasswordReset($user->firstname, $token)); + + //Mail::to($request->email)->queue(new ResetPassword()); $user['verification_token'] = $token; diff --git a/app/Mail/ResetPassword.php b/app/Mail/ResetPassword.php deleted file mode 100755 index 31ca7558..00000000 --- a/app/Mail/ResetPassword.php +++ /dev/null @@ -1,41 +0,0 @@ -name = $name; - $this->token = $token; - } - - /** - * Build the message. - * - * @return $this - */ - public function build() - { - $user['name'] = $this->name; - $user['token'] = $this->token; - - return $this->view('emails.reset-password', ['user' => $user]); - } -} diff --git a/app/Notifications/PasswordReset.php b/app/Notifications/PasswordReset.php new file mode 100644 index 00000000..410578ae --- /dev/null +++ b/app/Notifications/PasswordReset.php @@ -0,0 +1,66 @@ +name = $name; + $this->token = $token; + } + + /** + * 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) + { + $user['name'] = $this->name; + $user['token'] = $this->token; + + return $this->subject('Resetting your password') + ->view('emails.reset-password', ['user' => $user]); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} From cb800a802fd0c2a14085b127aca0a9bbb3c2a4ee Mon Sep 17 00:00:00 2001 From: ilmedova Date: Wed, 7 Dec 2022 15:13:52 +0500 Subject: [PATCH 3/4] returning mail message error fixed --- app/Notifications/PasswordReset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Notifications/PasswordReset.php b/app/Notifications/PasswordReset.php index 410578ae..60509a0d 100644 --- a/app/Notifications/PasswordReset.php +++ b/app/Notifications/PasswordReset.php @@ -47,7 +47,7 @@ public function toMail($notifiable) $user['name'] = $this->name; $user['token'] = $this->token; - return $this->subject('Resetting your password') + return (new MailMessage)->subject('Resetting your password') ->view('emails.reset-password', ['user' => $user]); } From 9901bca9dc51d0d4b5079e5ac1324f34fbab91ad Mon Sep 17 00:00:00 2001 From: ilmedova Date: Wed, 7 Dec 2022 15:28:40 +0500 Subject: [PATCH 4/4] email verification done --- app/Http/Controllers/API/ClientController.php | 15 +- app/Mail/EmailVerification.php | 41 ------ app/Notifications/ApplicationApproved.php | 3 +- app/Notifications/ApplicationRefined.php | 3 +- app/Notifications/EmailVerify.php | 66 +++++++++ app/Notifications/TicketMessage.php | 3 +- app/Notifications/TicketPosted.php | 3 +- .../views/emails/email-verification.blade.php | 129 ++++++++++-------- .../views/emails/reset-password.blade.php | 128 +++++++++-------- 9 files changed, 217 insertions(+), 174 deletions(-) delete mode 100755 app/Mail/EmailVerification.php create mode 100644 app/Notifications/EmailVerify.php diff --git a/app/Http/Controllers/API/ClientController.php b/app/Http/Controllers/API/ClientController.php index 60a265a7..7ce7bf2e 100644 --- a/app/Http/Controllers/API/ClientController.php +++ b/app/Http/Controllers/API/ClientController.php @@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Lang; use App\Http\Controllers\Controller; +use App\Notifications\EmailVerify; use App\Notifications\PasswordReset; class ClientController extends Controller @@ -69,16 +70,7 @@ public function signup(RegisterRequest $request){ if($email_verification) { $client->verification_token = rand(10000, 99999); - - //try{ - Mail::to($request->email) - ->queue(new EmailVerification($request->firstname, $client->verification_token)); - // }catch (\Exception $ex){ - // //eger email ugradyp bolmasa verification edip bolmaz - // $client->is_verified = true; - // Log::error($ex->getMessage()); - // } - + $client->notify(new EmailVerify($request->firstname, $client->verification_token)); } $account = Account::create([ @@ -87,7 +79,6 @@ public function signup(RegisterRequest $request){ ]); $client->account()->associate($account)->save(); - if($client->is_verified){ Auth::login($client); $client->token = $client->createToken('auth_token')->plainTextToken; @@ -157,8 +148,6 @@ public function sendPasswordResetLinkEmail(Request $request) { $user->notify(new PasswordReset($user->firstname, $token)); - //Mail::to($request->email)->queue(new ResetPassword()); - $user['verification_token'] = $token; $user->save(); diff --git a/app/Mail/EmailVerification.php b/app/Mail/EmailVerification.php deleted file mode 100755 index 57127453..00000000 --- a/app/Mail/EmailVerification.php +++ /dev/null @@ -1,41 +0,0 @@ -name = $name; - $this->token = $token; - } - - /** - * Build the message. - * - * @return $this - */ - public function build() - { - $user['name'] = $this->name; - $user['token'] = $this->token; - - return $this->subject('Verify your email') - ->view('emails.email-verification', ['user' => $user]); - } -} diff --git a/app/Notifications/ApplicationApproved.php b/app/Notifications/ApplicationApproved.php index 4eab4afd..400947e2 100644 --- a/app/Notifications/ApplicationApproved.php +++ b/app/Notifications/ApplicationApproved.php @@ -40,7 +40,8 @@ public function via($notifiable) */ public function toMail($notifiable) { - return (new MailMessage)->view('emails.notifications.application_approved'); + return (new MailMessage)->subject('Application approved!') + ->view('emails.notifications.application_approved'); } /** diff --git a/app/Notifications/ApplicationRefined.php b/app/Notifications/ApplicationRefined.php index 09774ab5..5f5995ad 100644 --- a/app/Notifications/ApplicationRefined.php +++ b/app/Notifications/ApplicationRefined.php @@ -40,7 +40,8 @@ public function via($notifiable) */ public function toMail($notifiable) { - return (new MailMessage)->view('emails.notifications.application_refined'); + return (new MailMessage)->subject('Application refined!') + ->view('emails.notifications.application_refined'); } /** diff --git a/app/Notifications/EmailVerify.php b/app/Notifications/EmailVerify.php new file mode 100644 index 00000000..540507bf --- /dev/null +++ b/app/Notifications/EmailVerify.php @@ -0,0 +1,66 @@ +name = $name; + $this->token = $token; + } + + /** + * 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) + { + $user['name'] = $this->name; + $user['token'] = $this->token; + + return (new MailMessage)->subject('Verify your email') + ->view('emails.email-verification', ['user' => $user]); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/TicketMessage.php b/app/Notifications/TicketMessage.php index 00d0cfb5..f9c82f02 100644 --- a/app/Notifications/TicketMessage.php +++ b/app/Notifications/TicketMessage.php @@ -40,7 +40,8 @@ public function via($notifiable) */ public function toMail($notifiable) { - return (new MailMessage)->view('emails.notifications.new_message'); + return (new MailMessage)->subject('You have new message!') + ->view('emails.notifications.new_message'); } /** diff --git a/app/Notifications/TicketPosted.php b/app/Notifications/TicketPosted.php index c912ab8b..e223c253 100644 --- a/app/Notifications/TicketPosted.php +++ b/app/Notifications/TicketPosted.php @@ -40,7 +40,8 @@ public function via($notifiable) */ public function toMail($notifiable) { - return (new MailMessage)->view('emails.notifications.new_ticket'); + return (new MailMessage)->subject('New ticket created.') + ->view('emails.notifications.new_ticket'); } /** diff --git a/resources/views/emails/email-verification.blade.php b/resources/views/emails/email-verification.blade.php index 287d33e6..3eb93ee6 100755 --- a/resources/views/emails/email-verification.blade.php +++ b/resources/views/emails/email-verification.blade.php @@ -1,71 +1,84 @@ - + - - - - - - - - - -
- + + + + +
+
+ +
+ - + + + + -
- - - -
-

- Hello {{ $user ? $user['name'] : '' }}, -

- Verify your email address! -

-

- Your code to verify email: -

+
+
+ -

- {{$user['token']}} -

- - - -
+

+ Подтверждение адреса электронной почты +

+ + +
+

+ Здравствуйте! +

-
+ + +

+ Вы указали текущий адрес электронной почты для регистрации в личном кабинете на сайте ГТСБТ.
+ Чтобы закончить регистрацию, подтвердите свой e-mail. Код подтверждения: {{$user['token']}} +

+ + + + +

+ С уважением,
+ отдел фин. мониторинга ГТСБТ. +

+ + + + + + + + + diff --git a/resources/views/emails/reset-password.blade.php b/resources/views/emails/reset-password.blade.php index 13b3384b..676256ff 100755 --- a/resources/views/emails/reset-password.blade.php +++ b/resources/views/emails/reset-password.blade.php @@ -1,71 +1,83 @@ - + - - - - - - - - - -
- + + + + +
+
+ +
+ - + + + + -
- - - -
-

- Hello {{ $user ? $user['name'] : '' }}, -

- We've received a request to reset the password. -

-

- Your code to reset: -

+
+
+ -

- {{$user['token']}} -

- - - -
+

+ Сброс пароля +

+ + +
+

+ Здравствуйте! +

-
+ + +

+ Код для сброса пароля: {{$user['token']}} +

+ + + + +

+ С уважением,
+ отдел фин. мониторинга ГТСБТ. +

+ + + + + + + + +