think.studio/laravel-email-change-verification
Composer 安装命令:
composer require think.studio/laravel-email-change-verification
包简介
Package allow add verification for new email when user change email
README 文档
README
Package allow to add verification for new email when user change email
Installation
You can install the package via composer:
composer require think.studio/laravel-email-change-verification php artisan vendor:publish --provider="EmailChangeVerification\ServiceProvider" --tag="config"
Configuration and usage
- Create migration. Package not provide default migrations, so you will need create table manually. But packages provide class with default columns.
public function up() { Schema::create('email_changes', function (\Illuminate\Database\Schema\Blueprint $table) { \EmailChangeVerification\Database\MigrationHelper::defaultColumns($table); }); } public function down() { Schema::dropIfExists('email_changes'); }
php artisan migrate
- Update User model
use EmailChangeVerification\User\HasEmailChangeVerification; use EmailChangeVerification\User\WithEmailChangeVerification; class User extends Authenticatable implements HasEmailChangeVerification { use WithEmailChangeVerification; // ... }
- Send verification on email change
if ($user->email != $request->input('email')) { $status = EmailChange::sendVerificationLink([ 'email' => $user->email, ], $request->input('email')); if ($status == EmailChange::VERIFICATION_LINK_SENT) { $successMessage = __($status); } else { throw ValidationException::withMessages([ 'email' => __($status), ]); } }
- Verify new email
// routes Route::get( '/email-change-verification/{token}', [ \App\Http\Controllers\Dashboard\ProfileController::class, 'verifyNewEmail', ] )->name('email.change.verification');
// controller public function verifyNewEmail( Request $request, string $token ) { $validator = Validator::make( array_merge($request->all(), [ 'token' => $token, ]), [ 'email' => [ 'required', 'email' ], 'new_email' => [ 'required', 'email' ], 'token' => [ 'required', 'string', 'max:64' ], ] ); if($validator->fails()) { abort(404); } $status = EmailChange::verify( [ 'email' => $request->input( 'email', '' ), 'new_email' => $request->input( 'new_email', '' ), 'token' => $token, ], function ( $user, string $newEmail ) { // user manipulation $user->email = $newEmail; $user->save(); } ); if ( $status != EmailChange::EMAIL_CHANGED ) { return __( $status ); // return view or redirect } return 'Success'; // return view or redirect }
- Check is request sent
// returns email or null if expired, Example: test@test.com $lastRequestedEmailChange = EmailChange::getRepository()->lastRequestedEmail($user);
Credits
think.studio/laravel-email-change-verification 适用场景与选型建议
think.studio/laravel-email-change-verification 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email-verification」 「email-change」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 think.studio/laravel-email-change-verification 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 think.studio/laravel-email-change-verification 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 think.studio/laravel-email-change-verification 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Email-Guard core library for PHP: local email checks (syntax, reserved TLDs, disposable domains) plus optional escalation to the EmailSherlock Verify API.
AbstractEmailValidation - Wrapper to quickly start using the powerful AbstractAPI's email validation service in your projects.
Symfony integration for Email-Guard: a VerifiedEmail constraint and a verify_email form option that block disposable and undeliverable addresses at submit time.
A robust Laravel package for generating and validating One-Time Passwords (OTP) with email integration, automatic cleanup, and comprehensive testing support for PHP 8.2+
Symfony bundle for secure email address changes with verification
Framework-agnostic PHP SDK for the BounceShift email-validation API.
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-26