定制 atnic/laravel-email-verification 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

atnic/laravel-email-verification

Composer 安装命令:

composer require atnic/laravel-email-verification

包简介

Laravel Email Verification Scaffolding

README 文档

README

Implementation

Laravel Email Verification is a package for generate scaffolding code for email verification within just few step.

But before that make sure you already config you .env especially for MAIL_* keys. I prefer you to set up using mailtrap.io, its super easy!

Okay, then this is the step to install Laravel Email Verification:

  • Install this package
composer require atnic/laravel-email-verification
  • Make sure you're already run php artisan make:auth before, then run
php artisan make:email-verification
  • Run migration to add email_verified column to users table
php artisan migrate
  • Add Atnic\EmailVerification\Traits\EmailVerifiable trait to User model.
<?php
...
use Atnic\EmailVerification\Traits\EmailVerifiable;
class User extends Authenticatable
{
    use EmailVerifiable;
    ...
  • In app/Http/Kernel.php, modify $routeMiddleware property, change auth middleware
<?php
...
class Kernel extends HttpKernel
{
    ...
    protected $routeMiddleware = [
        // 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth' => \Atnic\EmailVerification\Http\Middleware\Authenticate::class,
        ...
  • Override registered() method on RegisterController
<?php
...
use Atnic\EmailVerification\Notifications\EmailVerification;
class RegisterController extends Controller
{
    ...
    /**
     * The user has been registered.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function registered($request, $user)
    {
        $user->notify(new EmailVerification($user->generateEmailVerificationUrl()));
        if ($user->isEmailVerificationTimeoutExpired()) {
            auth()->logout();
            return response()->redirectToRoute('verify_email.resend', [ 'email' => $user->email ])->with('status', __('email-verification::verify_email.link_sent'));
        }
    }
    ...
  • Done!

Advance Usage

In User model you can add $emailVerificationTimeout using integer value that define how much time in minutes user can logged in even when their email is unverified yet. You can notify them that their email is not verified and can click this link to resend email verfication. route('verify_email.resend', [ 'email' => 'some_email' ]). The default is 0, so user can't be login if email is not verified.

Security Vulnerabilities

If you discover a security vulnerability within Laravel Email Verification, please send an e-mail to Farid Inawan via frdteknikelektro@gmail.com. All security vulnerabilities will be promptly addressed.

License

Laravel Email Verification is open-sourced package licensed under the MIT license.

统计信息

  • 总下载量: 186
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固