PHPackages                             think.studio/laravel-email-change-verification - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. think.studio/laravel-email-change-verification

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

think.studio/laravel-email-change-verification
==============================================

Package allow add verification for new email when user change email

1.2.0(2y ago)062MITPHPPHP ^8.0

Since May 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/dev-think-one/laravel-email-change-verification)[ Packagist](https://packagist.org/packages/think.studio/laravel-email-change-verification)[ Docs](https://github.com/dev-think-one/laravel-email-change-verification)[ RSS](/packages/thinkstudio-laravel-email-change-verification/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (6)Used By (0)

Laravel: Email change verification
==================================

[](#laravel-email-change-verification)

[![Packagist License](https://camo.githubusercontent.com/651dde64cd1be7e3fc42d2e1a885e2f396f308eeace0e252cea7f435d208a580/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7468696e6b2e73747564696f2f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e3f636f6c6f723d253233346463373166)](https://camo.githubusercontent.com/651dde64cd1be7e3fc42d2e1a885e2f396f308eeace0e252cea7f435d208a580/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7468696e6b2e73747564696f2f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e3f636f6c6f723d253233346463373166)[![Packagist Version](https://camo.githubusercontent.com/0eec9d5e9127ac2b3a4122c8e3d781eb9a57b39a7294e1e38ae326bf24ebe760/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468696e6b2e73747564696f2f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e)](https://packagist.org/packages/think.studio/laravel-email-change-verification)[![Total Downloads](https://camo.githubusercontent.com/c8efdf9d8e084575c7fdd4272e2cbf663a95cde37f5c8bf759f513e77e0140fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468696e6b2e73747564696f2f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e)](https://packagist.org/packages/think.studio/laravel-email-change-verification)[![Build Status](https://camo.githubusercontent.com/c1cf9e769dc9166fb451461bcdd9561c5e77fb1e3a8bdbffa4c2af17b1e55ac7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6465762d7468696e6b2d6f6e652f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e2f6261646765732f6275696c642e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/dev-think-one/laravel-email-change-verification/build-status/main)[![Code Coverage](https://camo.githubusercontent.com/fbe0f7691e46a49c437686064120f8ce6f63af28fa525e63f844e0776f53f315/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6465762d7468696e6b2d6f6e652f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e2f6261646765732f636f7665726167652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/dev-think-one/laravel-email-change-verification/?branch=main)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/af4b3fdd69627b42e9a366b069001d3466673ce6c454e7b556dec1b7dd0eb51b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6465762d7468696e6b2d6f6e652f6c61726176656c2d656d61696c2d6368616e67652d766572696669636174696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/dev-think-one/laravel-email-change-verification/?branch=main)

Package allow to add verification for new email when user change email

Installation
------------

[](#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
-----------------------

[](#configuration-and-usage)

1. 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
```

2. Update User model

```
use EmailChangeVerification\User\HasEmailChangeVerification;
use EmailChangeVerification\User\WithEmailChangeVerification;

class User extends Authenticatable implements HasEmailChangeVerification
{
    use WithEmailChangeVerification;
    // ...
}
```

3. 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),
        ]);
    }
}
```

4. 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
}
```

5. Check is request sent

```
// returns email or null if expired, Example: test@test.com
$lastRequestedEmailChange = EmailChange::getRepository()->lastRequestedEmail($user);
```

Credits
-------

[](#credits)

- [![Think Studio](https://camo.githubusercontent.com/8e541bece07d503c85a126b5294865faa00e27371048772f566a0cce8c01fd3a/68747470733a2f2f7961726f736c617777772e6769746875622e696f2f696d616765732f73706f6e736f72732f7061636b616765732f6c6f676f2d7468696e6b2d73747564696f2e706e67)](https://think.studio/)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~209 days

Total

5

Last Release

990d ago

PHP version history (2 changes)1.0.0PHP &gt;7.4

1.1.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/53f93fa87d58f33d106de6bd5e2946f8a345ebfaee146360746056cb134a15a0?d=identicon)[think.studio](/maintainers/think.studio)

---

Top Contributors

[![yaroslawww](https://avatars.githubusercontent.com/u/23663794?v=4)](https://github.com/yaroslawww "yaroslawww (8 commits)")

---

Tags

email-verificationemail change

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thinkstudio-laravel-email-change-verification/health.svg)

```
[![Health](https://phpackages.com/badges/thinkstudio-laravel-email-change-verification/health.svg)](https://phpackages.com/packages/thinkstudio-laravel-email-change-verification)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
