All Projects → josiasmontag → Laravel Email Verification

josiasmontag / Laravel Email Verification

Licence: mit
Laravel package to handle user verification using an activation mail

Projects that are alternatives of or similar to Laravel Email Verification

Laravel User Verification
PHP package built for Laravel 5.* to easily handle a user email verification and validate the email
Stars: ✭ 755 (+1098.41%)
Mutual labels:  laravel, laravel-package, laravel5, email-validation
Eye
Eyewitness.io package for Laravel 5 applications
Stars: ✭ 114 (+80.95%)
Mutual labels:  laravel, laravel-package, laravel-5-package, laravel5
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (-28.57%)
Mutual labels:  laravel, laravel-package, laravel-5-package, laravel5
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (+25.4%)
Mutual labels:  laravel, laravel-package, laravel-5-package, laravel5
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+265.08%)
Mutual labels:  laravel, laravel-package, laravel-5-package, laravel5
Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+406.35%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Generator
Laravel 5.3+ Scaffold Generator, Support both bootstrap and Semantic UI
Stars: ✭ 327 (+419.05%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Telegram
✈️ Telegram Notifications Channel for Laravel
Stars: ✭ 450 (+614.29%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Js Localization
🌐 Convert your Laravel messages and consume them in the front-end!
Stars: ✭ 451 (+615.87%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Framework
The truly Laravel E-commerce Framework
Stars: ✭ 456 (+623.81%)
Mutual labels:  laravel, laravel-package, laravel5
Orm
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen
Stars: ✭ 712 (+1030.16%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Administrator
a fork from Frozennode/Administrator
Stars: ✭ 296 (+369.84%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Achievements
Achievements for Laravel 5.3+
Stars: ✭ 279 (+342.86%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Server Monitor
Server Monitoring Command for Laravel Applications
Stars: ✭ 424 (+573.02%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Gamp
📊 Laravel Google Analytics Measurement Protocol Package
Stars: ✭ 271 (+330.16%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Nova-Dark-Theme
A dark theme for Laravel Nova
Stars: ✭ 72 (+14.29%)
Mutual labels:  laravel-package, laravel-5-package, laravel5
Angular5.2 Laravel5.6
Angular 5.2 and Laravel 5.6 Authentication and CRUD
Stars: ✭ 17 (-73.02%)
Mutual labels:  laravel, laravel-5-package, laravel5
Laravel Widgetize
A minimal package to help you make your laravel application cleaner and faster.
Stars: ✭ 791 (+1155.56%)
Mutual labels:  laravel, laravel-5-package, laravel5
Notifier
NO LIBRARIES socket per page bridge for your Laravel application. (CLIENT PART INCLUDED)
Stars: ✭ 57 (-9.52%)
Mutual labels:  laravel, laravel-5-package, laravel5
maintenance-mode
An enhanced maintenance mode for Laravel.
Stars: ✭ 117 (+85.71%)
Mutual labels:  laravel-package, laravel-5-package, laravel5

Build Status Total Downloads Latest Stable Version License

⚠️ Deprecation Warning: This package is still maintained but it does not get any new features. For new projects I recommend using Laravel's built in email verification.

Introduction

The Laravel Email Verification package is built for Laravel 5.4 and later to easily handle a user verification and validate the e-mail. It is inspired by crypto-based password resets and the email verification package by jrean.

  • [x] Crypto-based email verification. No need to store a temporary token in the database!
  • [x] Event based: No need to override your register() method.
  • [x] Using the Laravel 5.3 notification system.
  • [x] Allow certain routes for verified users only using the IsEmailVerified middleware.
  • [x] Let the users resend the verification email at anytime.
  • [x] Ready for Localization.

Configuration

To get started, use Composer to add the package to your project's dependencies:

composer require josiasmontag/laravel-email-verification

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just register the Lunaweb\EmailVerification\Providers\EmailVerificationServiceProvider in your config/app.php configuration file:

'providers' => [
    // Other service providers...

    Lunaweb\EmailVerification\Providers\EmailVerificationServiceProvider::class,
],

Migration

The table representing the user must be updated with a verified column. This update will be performed by the migrations included with this package.

To run the migrations from this package use the following command:

php artisan migrate --path="/vendor/josiasmontag/laravel-email-verification/database/migrations"

The package tries to guess your user table by checking what is set in the auth providers users settings. If this key is not found, the default App\User will be used to get the table name.

To customize the migration, publish it with the following command:

php artisan vendor:publish --provider="Lunaweb\EmailVerification\Providers\EmailVerificationServiceProvider" --tag="migrations"

User Model

The model representing the User must implement the CanVerifyEmail interface. The package comes with a CanVerifyEmail trait for a quick implementation. You can customize this trait in order to change the activation email.

use Illuminate\Foundation\Auth\User as Authenticatable;
use Lunaweb\EmailVerification\Traits\CanVerifyEmail;
use Lunaweb\EmailVerification\Contracts\CanVerifyEmail as CanVerifyEmailContract;

class User extends Authenticatable implements CanVerifyEmailContract
{

    use CanVerifyEmail;

    // ...
}

Register Controller

The package offers a VerifiesEmail trait for your RegisterController. You must update the middleware exception to allow verify routes to be access by authenticated users.

use Lunaweb\EmailVerification\Traits\VerifiesEmail;

class RegisterController extends Controller
{

    use RegistersUsers, VerifiesEmail;


    public function __construct()
    {
          $this->middleware('guest', ['except' => ['verify', 'showResendVerificationEmailForm', 'resendVerificationEmail']]);
          $this->middleware('auth', ['only' => ['showResendVerificationEmailForm', 'resendVerificationEmail']]);
    }

    // ...

}

There is no need to override register(). As default, the package listens for the Illuminate\Auth\Events\Registered event and sends the verification mail. You can disable this behavior using the listen_registered_event setting.

Routes

The package adds the following routes.

Route::get('register/verify', 'App\Http\Controllers\Auth\[email protected]')->name('verifyEmailLink');
Route::get('register/verify/resend', 'App\Http\Controllers\Auth\[email protected]')->name('showResendVerificationEmailForm');
Route::post('register/verify/resend', 'App\Http\Controllers\Auth\[email protected]')->name('resendVerificationEmail');

Middleware

To register the IsEmailVerified middleware add the following to the $routeMiddleware array within the app/Http/Kernel.php file:

protected $routeMiddleware = [
    // …
    'isEmailVerified' => \Lunaweb\EmailVerification\Middleware\IsEmailVerified::class,

Apply the middleware on your routes:

Route::group(['middleware' => ['web', 'auth', 'isEmailVerified']], function () {
    

Events

The package emits 2 events:

  • Lunaweb\EmailVerification\Events\EmailVerificationSent
  • Lunaweb\EmailVerification\Events\UserVerified

Resend the verification mail

Using the isEmailVerified Middleware, the following form is shown to the user. It allows the user to correct his email address and resend the verification mail.

Screenshot

You can manually point the user to this form using the showResendVerificationEmailForm route (Default: register/verify/resend).

To programmatically resend the verification mail:

$this->app->make('Lunaweb\EmailVerification\EmailVerification')->sendVerifyLink($user);

Customize the verification mail

Therefore, override sendEmailVerificationNotification() of your User model. Example:

class User implements CanVerifyEmailContract
{

    use CanVerifyEmail;

    /**
     * Send the email verification notification.
     *
     * @param  string  $token   The verification mail reset token.
     * @param  int  $expiration The verification mail expiration date.
     * @return void
     */
    public function sendEmailVerificationNotification($token, $expiration)
    {
        $this->notify(new MyEmailVerificationNotification($token, $expiration));
    }
}

Customize the resend form

php artisan vendor:publish --provider="Lunaweb\EmailVerification\Providers\EmailVerificationServiceProvider" --tag="views"

The template can be found in resources/views/vendor/emailverification/resend.blade.php

Customize the messages / localization

php artisan vendor:publish --provider="Lunaweb\EmailVerification\Providers\EmailVerificationServiceProvider" --tag="translations"

The localization files can be found in resources/lang/vendor/emailverification

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].