2017 © Pedro Peláez
 

library laravel-confirmation

laravel email confirmation package

image

viktor-miller/laravel-confirmation

laravel email confirmation package

  • Wednesday, March 14, 2018
  • by phpfriq
  • Repository
  • 1 Watchers
  • 1 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Laravel Email Confirmation

This package is intended to confirm the email address of the user. Tested and used with Laravel 5.4 and 5.5, (*1)

Features

  • Migration to add "confirmed" column to users table
  • Migration to create "email_confirmations" table
  • Scaffold for view, controller, routes and notification
  • Publish translations and configs
  • The validation rule for unconfirmed users. The validation rule supports an additional property for setting a pause in hours. For example: after registration, the user is allowed to log in for (n) hours without confirming the email address.
  • HTML form for resending a notification with instructions for confirming an email address
  • HTML form for confirmation of email address in manual mode (Enter e-mail and token).
  • Support for confirmation of the email address in the automatic mode (click on the link that was received by e-mail)

Installation

  1. Add package to your composer.json file:, (*2)

    composer require viktor-miller/laravel-confirmation
  2. For Laravel 5.4 add service provider and aliase to config/app.php, (*3)

'providers' => [
    ViktorMiller\LaravelConfirmation\ServiceProvider::class,
],
'aliases' => [
    'Confirmation' => ViktorMiller\LaravelConfirmation\Facades\Confirmation::class
]
  1. Add a Confirmable trait and implement Confirmable interface on your User model
<?php

namespace App\User;

use Illuminate\Notifications\Notifiable;
use ViktorMiller\LaravelConfirmation\Confirmable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use ViktorMiller\LaravelConfirmation\Contracts\Confirmable as ConfirmableContract;

class User extends Authenticatable implements Confirmable
{
    use Notifiable, Confirmable;
  1. Add validation rule in LoginController and ForgotPasswordController to restrict users with an unconfirmed email address., (*4)

    For Laravel >= 5.4:, (*5)

    LoginController, (*6)

<?php

namespace App\Http\Controllers\Auth;

class LoginController extends Controller
{
    /**
     * Validate the user login request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     */
    protected function validateLogin(Request $request)
    {
        $this->validate($request, [
            $this->username() => 'required|string|verified',
            'password' => 'required|string',
        ]);
    }

and ForgotPasswordController, (*7)

<?php

namespace App\Http\Controllers\Auth;

class ForgotPasswordController extends Controller
{ 
    /**
     * Validate the email for the given request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     */
    protected function validateEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email|verified']);
    }

For Laravel 5.5:, (*8)

LoginController, (*9)

<?php

namespace App\Http\Controllers\Auth;

use ViktorMiller\LaravelConfirmation\Rules\Verified;

class LoginController extends Controller
{
    /**
     * Validate the user login request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     */
    protected function validateLogin(Request $request)
    {
        $this->validate($request, [
            $this->username() => ['required', 'string', new Verified],
            'password' => 'required|string',
        ]);
    }

and ForgotPasswordController, (*10)

<?php

namespace App\Http\Controllers\Auth;

use ViktorMiller\LaravelConfirmation\Rules\Verified;

class ForgotPasswordController extends Controller
{ 
    /**
     * Validate the email for the given request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     */
    protected function validateEmail(Request $request)
    {
        $this->validate($request, [
            'email' => ['required', 'email', new Verified]
        ]);
    }
  1. Add event listener to Illuminate\Auth\Events\Registered
<?php

namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'Illuminate\Auth\Events\Registered' => [
            'ViktorMiller\LaravelConfirmation\Listeners\EmailConfirmation'
        ]
    ];
  1. Run migrations, (*11)

    php artisan migrate
  2. Run artisan confirmation command, (*12)

    php artisan confirmation

Publish

If you want to do some changes or add a language you can publish translations, (*13)

php artisan vendor:publish --tag=confirmation:translations

If you want to do some changes on config you can publish config, (*14)

php artisan vendor:publish --tag=confirmation:config

Console

supported options, (*15)

php artisan confirmation -h

Validation

If you want to allow users to ignore the verification rule "verified" for a certain number of hours (for example 24h):, (*16)

for Laravel >= 5.4, (*17)

$this->validate($request, [
    'email' => 'required|email|verified:24'
]);

for Laravel >= 5.5, (*18)

use ViktorMiller\LaravelConfirmation\Rules\Verified;

$this->validate($request, [
        'email' => ['required', 'string', new Verified(24)
    ],
]);

The Versions

14/03 2018

dev-master

9999999-dev

laravel email confirmation package

  Sources   Download

MIT

The Requires

 

by Viktor Miller

12/02 2018

1.0.5

1.0.5.0

laravel email confirmation package

  Sources   Download

MIT

The Requires

 

by Viktor Miller

10/02 2018

1.0.4

1.0.4.0

laravel email confirmation package

  Sources   Download

MIT

The Requires

 

by Viktor Miller

04/01 2018

1.0.1

1.0.1.0

laravel email confirmation package

  Sources   Download

MIT

The Requires

 

by Viktor Miller

03/01 2018

1.0.0

1.0.0.0

laravel email confirmation package

  Sources   Download

MIT

The Requires

 

by Viktor Miller