bestmomo / laravel-email-confirmation
使用Laravel进行邮箱地址确认
V1.1.5
2018-07-31 16:49 UTC
Requires
- php: >=5.6.4
- illuminate/support: ~5.4
README
此包用于将邮箱确认功能添加到Laravel 5.4或5.5项目。
应在运行php artisan make:auth
命令之后使用,但也可用于现有项目。
关于此包的法语介绍。
功能
- 创建迁移,将确认列添加到用户表
- 创建确认路由
confirmation/resend
confirmation/{id}/{token}
- 添加Artisan命令以覆盖登录和注册视图
- 注册时发送邮件通知
- 添加通知的翻译(有法语、英语、阿拉伯语、瑞典语和西班牙语翻译版本)
- 阻止未确认用户的登录,并发送带有重发链接的通知警报
- 阻止未确认用户在密码重置时的自动登录
安装
将包添加到您的composer.json文件中
composer require bestmomo/laravel-email-confirmation
对于Laravel 5.4,将服务提供者添加到config/app.php
(在Laravel 5.5中,有包发现功能)
Bestmomo\LaravelEmailConfirmation\ServiceProvider::class,
从V1.1.5开始,您必须使用以下命令发布迁移
php artisan vendor:publish --provider="Bestmomo\LaravelEmailConfirmation\ServiceProvider" --tag="confirmation:migrations"
运行已发布的迁移
php artisan migrate
在LoginController
中更改特质引用
use Bestmomo\LaravelEmailConfirmation\Traits\AuthenticatesUsers;
在RegisterController
中更改特质引用
use Bestmomo\LaravelEmailConfirmation\Traits\RegistersUsers;
在ResetPasswordController
中更改特质引用
use Bestmomo\LaravelEmailConfirmation\Traits\ResetsPasswords;
发布
- 如果您已使用
php artisan make:auth
命令
覆盖登录和注册视图以获取确认警报
php artisan confirmation:auth
- 如果您有自定义脚手架
您必须在登录和注册视图中添加警报。以下是使用Bootstrap的2个示例。
登录视图
@if (session('confirmation-success'))
<div class="alert alert-success">
{{ session('confirmation-success') }}
</div>
@endif
@if (session('confirmation-danger'))
<div class="alert alert-danger">
{!! session('confirmation-danger') !!}
</div>
@endif
注册视图
@if (session('confirmation-success'))
<div class="alert alert-success">
{{ session('confirmation-success') }}
</div>
@endif
可选发布
如果您想进行更改或添加语言,可以发布翻译
php artisan vendor:publish --tag=confirmation:translations
如果您想对确认通知进行更改,可以在App中创建副本
php artisan confirmation:notification