From aa4d32aa2fa0774597d909339ed14fe79ce3b63c Mon Sep 17 00:00:00 2001 From: kiritokatklian Date: Mon, 3 May 2021 21:34:45 +0200 Subject: [PATCH 1/2] [Update] Email Verification - Added VerifyEmail notification - Updated email verification theme --- app/Models/User.php | 11 ++++++++ app/Notifications/ResetPassword.php | 11 ++++---- app/Notifications/VerifyEmail.php | 25 +++++++++++++++++++ config/app.php | 4 +-- .../views/vendor/mail/html/message.blade.php | 2 +- .../views/vendor/mail/text/message.blade.php | 1 + routes/Web/Authentication.php | 2 +- 7 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 app/Notifications/VerifyEmail.php diff --git a/app/Models/User.php b/app/Models/User.php index 60ffdedd0..580d10ff6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -17,6 +17,7 @@ use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract; use Cog\Laravel\Love\Reacterable\Models\Traits\Reacterable; use App\Notifications\ResetPassword as ResetPasswordNotification; +use App\Notifications\VerifyEmail as VerifyEmailNotification; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -606,6 +607,16 @@ function receipt(): HasOne return $this->hasOne(UserReceipt::class); } + /** + * Send the email verification notification. + * + * @return void + */ + public function sendEmailVerificationNotification() + { + $this->notify(new VerifyEmailNotification); + } + /** * Send the password reset notification. * diff --git a/app/Notifications/ResetPassword.php b/app/Notifications/ResetPassword.php index 04c9640c7..2d064d78b 100644 --- a/app/Notifications/ResetPassword.php +++ b/app/Notifications/ResetPassword.php @@ -4,7 +4,6 @@ use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification; use Illuminate\Notifications\Messages\MailMessage; -use Illuminate\Support\Facades\Lang; class ResetPassword extends ResetPasswordNotification { @@ -20,13 +19,13 @@ protected function buildMailMessage($url): MailMessage $expirationDuration = $expirationDuration / 60; return (new MailMessage) - ->subject(Lang::get('Reset Your Kurozora ID Password')) - ->line(Lang::get('You recently made a request to reset your Kurozora ID. Please click the button below to complete the process.')) - ->line(Lang::get('This password reset link will expire in :count hours.', [ + ->subject(__('Reset your Kurozora ID password')) + ->line(__('You recently made a request to reset your Kurozora ID. Please click the button below to complete the process.')) + ->line(__('This password reset link will expire in :count hours.', [ 'count' => $expirationDuration ])) - ->action(Lang::get('Reset Password'), $url) - ->line(Lang::get('If you did not request a password reset, it’s likely that another user has entered your email address by mistake and your account is still secure. If you believe an unauthorized person has accessed your account, you can reset your password at kurozora.app.')) + ->action(__('Reset Password'), $url) + ->line(__('If you did not request a password reset, it’s likely that another user has entered your email address by mistake and your account is still secure. If you believe an unauthorized person has accessed your account, you can reset your password at [kurozora.app](:url).', ['url' => config('app.url')])) ->salutation('Kurozora Support'); } } diff --git a/app/Notifications/VerifyEmail.php b/app/Notifications/VerifyEmail.php new file mode 100644 index 000000000..37bf06886 --- /dev/null +++ b/app/Notifications/VerifyEmail.php @@ -0,0 +1,25 @@ +subject(__('Verify your Kurozora ID email address')) + ->line(__('You have recently created a Kurozora account. Please click the button below to verify this email address belongs to you.')) + ->action(__('Verify Email Address'), $url) + ->line(__('If you did not creat an account, it’s likely that another user has entered your email address by mistake. Don’t worry, to reclaim ownership you can reset the password at [kurozora.app/forgot-password](:url).', ['url' => route('password.request')])) + ->salutation('Kurozora Support'); + } +} diff --git a/config/app.php b/config/app.php index 064a88fe3..3507fce95 100644 --- a/config/app.php +++ b/config/app.php @@ -38,7 +38,7 @@ | or any other location as required by the application or its packages. */ - 'version' => '1.2.0-alpha.41', + 'version' => '1.2.0-alpha.42', /* |-------------------------------------------------------------------------- @@ -89,7 +89,7 @@ | */ - 'url' => env('APP_URL', 'http://localhost'), + 'url' => env('APP_URL', 'https://kurozora.app'), 'asset_url' => env('ASSET_URL', null), diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php index cd0cf3a0d..a9a69cef3 100644 --- a/resources/views/vendor/mail/html/message.blade.php +++ b/resources/views/vendor/mail/html/message.blade.php @@ -2,7 +2,7 @@ {{-- Header --}} @slot('header') @component('mail::header', ['url' => config('app.url')]) - {{ config('app.name') }} + {{ config('app.name') }} @endcomponent @endslot diff --git a/resources/views/vendor/mail/text/message.blade.php b/resources/views/vendor/mail/text/message.blade.php index 437cbdc72..2081943ac 100644 --- a/resources/views/vendor/mail/text/message.blade.php +++ b/resources/views/vendor/mail/text/message.blade.php @@ -15,6 +15,7 @@ @slot('subcopy') @component('mail::subcopy') {{ $subcopy }} +
@endcomponent @endslot @endisset diff --git a/routes/Web/Authentication.php b/routes/Web/Authentication.php index 4d19bddf5..50e2ef34b 100644 --- a/routes/Web/Authentication.php +++ b/routes/Web/Authentication.php @@ -55,7 +55,7 @@ ->name('.email'); Route::get('/reset-password/{token}', [NewPasswordController::class, 'create']) - ->middleware('guest') + ->middleware(['guest']) ->name('.reset'); Route::post('/reset-password', [NewPasswordController::class, 'store']) From c0a25d8e4e3fe26812294a6e57cd510c7388df07 Mon Sep 17 00:00:00 2001 From: kiritokatklian Date: Mon, 3 May 2021 21:39:00 +0200 Subject: [PATCH 2/2] [Remove] Confirm Email - Removed the now unused ConfirmEmail notification --- app/Mail/ConfirmEmail.php | 45 --------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 app/Mail/ConfirmEmail.php diff --git a/app/Mail/ConfirmEmail.php b/app/Mail/ConfirmEmail.php deleted file mode 100644 index 19ec26d71..000000000 --- a/app/Mail/ConfirmEmail.php +++ /dev/null @@ -1,45 +0,0 @@ -user = $user; - } - - /** - * Build the message. - * - * @return $this - */ - public function build(): static - { - return $this - ->subject('Please confirm your email address') - ->view('email.confirmation_email') - ->with([ - 'title' => 'Your Kurozora account registration', - 'username' => $this->user->username, - 'verification_url' => route('verification.verify') - ]); - } -}