Email verification feature
Quickly updated while reworking with livewire, might not be accurate.
Setup
1. Enable feature in config
Before delving into the code, make sure this feature is enabled in the config. By default, the feature is enabled, and can be found in config/portal.php. Look for the features.email_verification key, and make sure its set to true
2. Check email verification routes
Three routes are needed for this feature to work. These routes can be found in the latest portal/routes/application.php.stub. These files are automatically copied to your project when creating the application, they might not be up to date with the latest version however. The latest version should look something like this
// LOGGED IN
Route::group(['middleware' => array_filter([
'qore-portal-auth',
])],
function (): void {
Route::get('/email/verify', VerifyEmailCard::class)->name('verification.notice');
Route::get('/email/verified', VerifiedEmailCard::class)->name('verification.verified');
Route::get('/email/verify/{id}/{hash}', EmailVerificationVerify::class)
->middleware(['signed', 'throttle:6,1'])
->name('verification.verify');
});3. Implement MustVerifyEmail trait in User model
Make sure to add the HasVerifyEmailNotification trait to the user model so it will receive an email to verify its email address before being allowed to access the platform.
QoreAdminBaseUser implements the required sendEmailNotification method, but it uses an incompatible implementation. If you see errors like this Route [verification.verify] does not exist, then you probably forgot to use the HasVerifyEmailNotification trait.
use QoreWorksBusiness\QoreFrontend\Concerns\HasVerifyEmailNotification;
class User extends QoreAdminBaseUser implements MustVerifyEmail
{
use HasVerifyEmailNotification;
}Configuration
*This might need expanding. Some configuration might be hidden and yet to be discovered in the code base
| Key | Type | Default | Description |
|---|---|---|---|
| features.email_verification | bool | true | Enable email verification feature |
| feature_config.email_verification.verify_route | string | application.portal.verification.verify | Route name for email verification. Used as route-url in the email. |
| feature_config.email_verification.verified_route | string | application.portal.verification.verified | Route name for email verified page. Used as redirect after verify. |
| feature_config.email_verification.user_is_verified_route | string | application.portal.dashboard | Route name for dashboard. Used as redirect when already verified. |