Download the PHP package codicastudio/verify-new-email without Composer
On this page you can find all versions of the php package codicastudio/verify-new-email. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codicastudio/verify-new-email
More information about codicastudio/verify-new-email
Files in codicastudio/verify-new-email
Package verify-new-email
Short Description A random Codica Studio package.
License MIT
Homepage https://github.com/codicastudio/verify-new-email
Informations about the package verify-new-email
Laravel Verify New Email
Laravel supports verifying email addresses out of the box. This package adds support for verifying new email addresses. When a user updates its email address, it won't replace the old one until the new one is verified. Super easy to set up, still fully customizable. If you want it can be used as a drop-in replacement for the built-in Email Verification features as this package supports unauthenticated verification and auto-login. Support for Laravel 6.0 and higher and requires PHP 7.2 or higher.
Installation
You can install the package via composer:
Configuration
Publish the database migration, config file and email view:
You can set the redirect path in the verify-new-email.php
config file. The user will be redirected to this path after verification.
The expire time of the verification URLs can be changed by updating the auth.verification.expire
setting and defaults to 60 minutes.
Usage
Add the MustVerifyNewEmail
trait to your User
model and make sure it implements the framework's MustVerifyEmail
interface as well.
Now your User
model has a few new methods:
The newEmail
method doesn't update the user, its current email address stays current until the new one if verified. It stores a token (associated to the user and new email address) in the pending_user_emails
table. Once the user verifies the email address by clicking the link in the mail, the user model will be updated and the token will be removed from the pending_user_emails
table.
The resendPendingEmailVerificationMail
does exactly the same, it just grabs the new email address from the previous attempt.
Login after verification
The user that verified its email address will be logged in automatically. You can disable this by chaning the login_after_verification
configuration setting to false
.
Overriding the default Laravel Email Verification
The default Laravel implementation requires the user to be logged in before it can verify its email address. If you want to use this package's logic to handle that first verification flow as well, override the sendEmailVerificationNotification
method as shown below.
Customization
You can change the content of the verification mail by editing the published views which can be found in the resources/views/vendor/verify-new-email
folder. The verifyNewEmail.blade.php
view will be sent when verifying updated email addresses. The verifyFirstEmail.blade.php
view will be sent when a User verifies its initial email address for the first time (after registering). Alternatively you set your own custom Mailables classes in the config file:
You can also override the sendPendingEmailVerificationMail
method to change the behaviour of sending the verification mail:
The package has a controller to handle the activation of the new email address. You can specify a custom route in the config file which will be used to generate the verification URL. The token will be passed in as a parameter and the URL will be signed.