Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Update] Email Verification #133

Merged
merged 2 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions app/Mail/ConfirmEmail.php

This file was deleted.

11 changes: 11 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
11 changes: 5 additions & 6 deletions app/Notifications/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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');
}
}
25 changes: 25 additions & 0 deletions app/Notifications/VerifyEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Notifications;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Auth\Notifications\VerifyEmail as VerifyEmailNotification;

class VerifyEmail extends VerifyEmailNotification
{
/**
* Get the verify email notification mail message for the given URL.
*
* @param string $url
* @return MailMessage
*/
protected function buildMailMessage($url): MailMessage
{
return (new MailMessage)
->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');
}
}
4 changes: 2 additions & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -89,7 +89,7 @@
|
*/

'url' => env('APP_URL', 'http://localhost'),
'url' => env('APP_URL', 'https://kurozora.app'),

'asset_url' => env('ASSET_URL', null),

Expand Down
2 changes: 1 addition & 1 deletion resources/views/vendor/mail/html/message.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
<img height="50px" width="50px" src="{{ asset('images/static/icon/logo.png') }}" alt="{{ config('app.name') }}">
@endcomponent
@endslot

Expand Down
1 change: 1 addition & 0 deletions resources/views/vendor/mail/text/message.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
<br>
@endcomponent
@endslot
@endisset
Expand Down
2 changes: 1 addition & 1 deletion routes/Web/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down