https://github.com/viktor-miller/laravel-confirmation
Laravel email confirmation package
https://github.com/viktor-miller/laravel-confirmation
confirmation email laravel
Last synced: 6 months ago
JSON representation
Laravel email confirmation package
- Host: GitHub
- URL: https://github.com/viktor-miller/laravel-confirmation
- Owner: viktor-miller
- License: mit
- Created: 2018-01-03T14:15:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-14T21:05:57.000Z (over 8 years ago)
- Last Synced: 2024-04-17T03:55:43.383Z (about 2 years ago)
- Topics: confirmation, email, laravel
- Language: PHP
- Size: 109 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Email Confirmation #
This package is intended to confirm the email address of the user. **Tested and used with Laravel 5.4 and 5.5**
## Features ##
- Migration to add "confirmed" column to users table
- Migration to create "email_confirmations" table
- Scaffold for view, controller, routes and notification
- Publish translations and configs
- The validation rule for unconfirmed users. The validation rule supports an additional property for setting a pause in hours. For example: after registration, the user is allowed to log in for (n) hours without confirming the email address.
- HTML form for resending a notification with instructions for confirming an email address
- HTML form for confirmation of email address in manual mode (Enter e-mail and token).
- Support for confirmation of the email address in the automatic mode (click on the link that was received by e-mail)
## Installation ##
1. Add package to your **composer.json** file:
composer require viktor-miller/laravel-confirmation
2. For Laravel 5.4 add service provider and aliase to **config/app.php**
```php
'providers' => [
ViktorMiller\LaravelConfirmation\ServiceProvider::class,
],
'aliases' => [
'Confirmation' => ViktorMiller\LaravelConfirmation\Facades\Confirmation::class
]
```
3. Add a **Confirmable** trait and implement **Confirmable** interface on your User model
```php
= 5.4:
LoginController
```php
validate($request, [
$this->username() => 'required|string|verified',
'password' => 'required|string',
]);
}
```
and ForgotPasswordController
```php
validate($request, ['email' => 'required|email|verified']);
}
```
For Laravel 5.5:
LoginController
```php
validate($request, [
$this->username() => ['required', 'string', new Verified],
'password' => 'required|string',
]);
}
```
and ForgotPasswordController
```php
validate($request, [
'email' => ['required', 'email', new Verified]
]);
}
```
5. Add event listener to **Illuminate\Auth\Events\Registered**
```php
[
'ViktorMiller\LaravelConfirmation\Listeners\EmailConfirmation'
]
];
```
6. Run migrations
php artisan migrate
7. Run artisan confirmation command
php artisan confirmation
## Publish ##
If you want to do some changes or add a language you can publish translations
php artisan vendor:publish --tag=confirmation:translations
If you want to do some changes on config you can publish config
php artisan vendor:publish --tag=confirmation:config
### Console ###
supported options
php artisan confirmation -h
### Validation ###
If you want to allow users to ignore the verification rule "verified" for a certain number of hours (for example 24h):
for Laravel >= 5.4
```php
$this->validate($request, [
'email' => 'required|email|verified:24'
]);
```
for Laravel >= 5.5
```php
use ViktorMiller\LaravelConfirmation\Rules\Verified;
$this->validate($request, [
'email' => ['required', 'string', new Verified(24)
],
]);
```