tjbp/laravel-verify-emails

This package is abandoned and no longer maintained. No replacement package was suggested.

Verify email addresses in Laravel <5.7 using the same pattern as password resets.

v1.0.4 2020-06-15 11:52 UTC

This package is auto-updated.

Last update: 2020-06-15 12:34:02 UTC


README

StyleCI Build Status Total Downloads Latest Stable Version Latest Unstable Version License

This package allows you to verify account emails in Laravel using the same pattern as password resets.

DEPRECATED: Email verification was implemented in the Laravel Framework for the release of 5.7 - if you're using 5.7 or above this package is unnecessary and if you're using a release below 5.6 it's no longer officially supported and you shouldn't be. This package will no longer be maintained.

Installation

This package is installable with Composer via Packagist.

Configuration

Add the following to config/auth.php:

'verify_emails' => [
    'users' => [
        'provider' => 'users',
        'email' => 'auth.emails.verify',
        'table' => 'email_tokens',
        'expire' => 60,
    ],
],

Change the passwords.users.table setting to email_tokens too, allowing password reset and email verification tokens to use the same table. Alternatively, create a new table for the email verification tokens using the same definitions as your password resets table and configure the above accordingly.

Usage

Implement the LaravelVerifyEmails\Contracts\Auth\CanVerifyEmail contract in your App\User model and use the LaravelVerifyEmails\Auth\VerifyEmails\CanVerifyEmail trait to include the necessary methods. By default, a boolean column on your users table named verified is expected. This behaviour can be altered by overriding the methods in the trait.

Add the LaravelVerifyEmails\Auth\VerifyEmails\VerifyEmailServiceProvider::class service provider to the providers array in config/app.php.

Run php artisan make:verify-emails to generate views, routes and a controller. Alternatively, use the LaravelVerifyEmails\Foundation\Auth\VerifiesEmails trait in a controller of your choice.

Finally, call $user->unverify() to mark the user as unverified and send a verification token to their email address. To catch unverified users, replace the auth route middleware in App\Http\Kernel with \LaravelVerifyEmails\Auth\Middleware\AuthenticateAndVerifyEmail::class. If you'd rather use your own middleware, or want to check if a user is verified elsewhere, call $user->isVerified().

Licence

Laravel Verify Email is open-sourced software licensed under the MIT license.