Package Data | |
---|---|
Maintainer Username: | beyondcode |
Maintainer Contact: | marcel@beyondco.de (Marcel Pociot) |
Package Create Date: | 2018-04-30 |
Package Last Update: | 2024-04-05 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:04:11 |
Package Statistics | |
---|---|
Total Downloads: | 47,985 |
Monthly Downloads: | 439 |
Daily Downloads: | 26 |
Total Stars: | 544 |
Total Watchers: | 17 |
Total Forks: | 55 |
Total Open Issues: | 0 |
You can install the package via composer:
composer require beyondcode/laravel-confirm-email
This package adds a confirmed_at
and confirmation_code
field to your users table.
Publish the migration and the configuration file using
php artisan vendor:publish --provider=BeyondCode\EmailConfirmation\EmailConfirmationServiceProvider
And run the migrations:
php artisan migrate
In order to make use of the email verification, replace the AuthenticatesUsers
, RegistersUsers
and the SendsPasswordResetEmails
traits that
come with Laravel, with the ones provided by this package.
These traits can be found in these three files:
App\Http\Controllers\Auth\LoginController
App\Http\Controllers\Auth\RegisterController
App\Http\Controllers\Auth\ForgotPasswordController
Add the following two routes to your routes/web.php
file:
Route::name('auth.resend_confirmation')->get('/register/confirm/resend', 'Auth\RegisterController@resendConfirmation');
Route::name('auth.confirm')->get('/register/confirm/{confirmation_code}', 'Auth\RegisterController@confirm');
This packages adds some flash messages that contain error/information messages for your users.
To show them to your users, add this to your login.blade.php
:
@if (session('confirmation'))
<div class="alert alert-info" role="alert">
{!! session('confirmation') !!}
</div>
@endif
and this to both your login.blade.php
and email.blade.php
@if ($errors->has('confirmation') > 0 )
<div class="alert alert-danger" role="alert">
{!! $errors->first('confirmation') !!}
</div>
@endif
This package comes with a language file, that allows you to modify the error / confirmation messages that your user
might see. In addition to that, you can change the notification class that will be used to send the confirmation code
completely, by changing it in the config/confirmation.php
file.
You can change all possible redirect routes by including these values either as properties in your registration controller, or as methods returning the route/URL string:
redirectConfirmationTo
redirectAfterRegistrationTo
redirectAfterResendConfirmationTo
They all default to route('login')
.
On successful email confirmation, this package dispatches a Confirmed
event, in order for you to conveniently handle
any custom logic, such as sending a welcome email or automatically logging the user in.
Simply add the Confirmed
event, and your listeners, to the EventServiceProvider
in your application:
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'BeyondCode\EmailConfirmation\Events\Confirmed' => [
'App\Listeners\YourOnConfirmedListener'
]
];
For more information about registering events and listeners, please refer to the Laravel docs.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.