定制 jersyfi/laravel-verify-email 二次开发

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

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

jersyfi/laravel-verify-email

Composer 安装命令:

composer require jersyfi/laravel-verify-email

包简介

A package for email verification in laravel

README 文档

README

Packagist Downloads Packagist Version GitHub License

Simple designed email verification based on the laravel email verification features. Verify Email publishes the scaffolding to your laravel application that can be easily customized based on your own application's needs. The easiest way is to use laravel breeze because it is designed the same way.

It is suggested to use laravel breeze but you don't need to. When you are not using the suggested package please get familiar with laravel email verification before starting here.

Installation

It is also easy to install this package.

composer require jersyfi/laravel-verify-email

php artisan verify-email:install

Prepare your application

The user model needs to use the trait MustVerifyNewEmail. Also it is necessary to override the default function sendEmailVerificationNotification.

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Notifications\Notifiable;
use App\Traits\Auth\MustVerifyNewEmail;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable, MustVerifyNewEmail;
    
    public function sendEmailVerificationNotification()
    {
        $this->newEmail($this->getEmailForVerification());
    }
}

In the routes you need to add the following example. You are free to customize your route name but keep in mind to update it in your config or in your auth trait MustVerifyNewEmail. The redirect route after verification can be changed in config or in the controller VerifyNewEmailController.

use App\Http\Controllers\Auth\VerifyNewEmailController;

Route::get('/verify-email/{id}/{hash}', [VerifyNewEmailController::class, '__invoke'])
    ->middleware(['auth', 'signed', 'throttle:6,1'])
    ->name('verification.verify');

At least you need to migrate the %_create_pending_user_emails.php migration.

php artisan migrate

Configuration

The configuration can be made in the config file verify-email or in the published files. All config values have there used file path.

For the verification url the route.for is required or go to app/Traits/Auth/MustVerifyNewEmail and change it in function verificationUrl. When calling the varification link the route.after is required to redirect or go to app/Http/Controllers/Auth/VerifyNewEmailController and change it in function __invoke.

'route' => [
    'for' => 'verification.verify',
    'after' => 'home',
],

You can decide if the user's verification status resets on every email change or go to app/Traits/Auth/MustVerifyNewEmail and change it in function newEmail.

'reset_verification' => true,

You can change the active time of the verification link with a number in minutes or go to app/Traits/Auth/MustVerifyNewEmail and change it in function verificationUrl.

'expire' => 60,

Usage

When you want to change to user's email you can call the user function syncEmail.

$request->user()->syncEmail($request->input('email'));

If you need to get the pending email you can call the user function getPendingEmail.

$request->user()->getPendingEmail();

In case you need to clear the user's pending email call clearPendingEmail.

$request->user()->clearPendingEmail();

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

This package was inspired by the Laravel Verify New Email package by Protone Media.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固