Giter Site home page Giter Site logo

laravel-confirm-email's Introduction

Laravel Email Confirmation

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require beyondcode/laravel-confirm-email

Usage

This package adds a confirmed_at and confirmation_code field to your users table. Publish the migration and the configuration file using

php artisan vendor:publish --provider="BeyondCode\EmailConfirmation\EmailConfirmationServiceProvider"

And run the migrations:

php artisan migrate

Configuring the login, register and forgot password controllers

In order to make use of the email verification, replace the AuthenticatesUsers, RegistersUsers and the SendsPasswordResetEmails traits that come with Laravel, with the ones provided by this package.

These traits can be found in these three files:

  • App\Http\Controllers\Auth\LoginController
  • App\Http\Controllers\Auth\RegisterController
  • App\Http\Controllers\Auth\ForgotPasswordController

Add the confirmation and resend routes

Add the following two routes to your routes/web.php file:

Route::name('auth.resend_confirmation')->get('/register/confirm/resend', 'Auth\RegisterController@resendConfirmation');
Route::name('auth.confirm')->get('/register/confirm/{confirmation_code}', 'Auth\RegisterController@confirm');

Show confirmation messages

This packages adds some flash messages that contain error/information messages for your users. To show them to your users, add this to your login.blade.php:

@if (session('confirmation'))
    <div class="alert alert-info" role="alert">
        {!! session('confirmation') !!}
    </div>
@endif

and this to both your login.blade.php and email.blade.php

@if ($errors->has('confirmation') > 0 )
    <div class="alert alert-danger" role="alert">
        {!! $errors->first('confirmation') !!}
    </div>
@endif

Customization

This package comes with a language file, that allows you to modify the error / confirmation messages that your user might see. In addition to that, you can change the notification class that will be used to send the confirmation code completely, by changing it in the config/confirmation.php file.

Change redirect routes

You can change all possible redirect routes by including these values either as properties in your registration controller, or as methods returning the route/URL string:

  • redirectConfirmationTo
  • redirectAfterRegistrationTo
  • redirectAfterResendConfirmationTo

They all default to route('login').

The Confirmed Event

On successful email confirmation, this package dispatches a Confirmed event, in order for you to conveniently handle any custom logic, such as sending a welcome email or automatically logging the user in.

Simply add the Confirmed event, and your listeners, to the EventServiceProvider in your application:

    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'BeyondCode\EmailConfirmation\Events\Confirmed' => [
            'App\Listeners\YourOnConfirmedListener'
        ]
    ];

For more information about registering events and listeners, please refer to the Laravel docs.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-confirm-email's People

Contributors

brandonsurowiec avatar chapeupreto avatar cmrd-senya avatar colinmackinlay avatar kslr avatar mechelon avatar mpociot avatar rickwest avatar sschlein avatar svenluijten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-confirm-email's Issues

Remove "confirmation::" on the __()

When using translations for the messages that the package sends the confirmation:: part in the translate method is failing code that doesn't show the message.

What it is as of right now:
->with('confirmation', __('confirmation::confirmation.confirmation_resent'));

What it's supposed to be:
->with('confirmation', __('confirmation.confirmation_resent'));

Password reset bypasses confirmation

Hi

Currently if you register as a new user, do not use the confirmation email link, but then use the Auth password retrieval you can reset your password and log in successfully without email confirmation preventing log in.

I don't see an issue in this, in the fact that the user is essentially having to receive an email and action it to get the reset link.

However it is a usability issue, in that the next time the user logs in, they will then get the prompt saying their email is not confirmed. Even though they had previously logged in successfully.

Perhaps it would make sense for the password reset mechanism to also perform the confirmation action if still outstanding?

Thanks

Tom

Everything seems to work except creating confirmation_code and sending e-mail

I'm running a dockerized version of laravel and I've been attempting to get this functionality to work with.
Laravel Framework 5.6.39
Ubuntu 16.04
DebugBar doesn't show any problems,

composer require ... worked fine
vendor:publish ... worked fine and migration ran no problem.

added the routes.

updated the Controllers.
added the alert blocks.

rebuilt, and when I try to login, it warns that i'm not confirmed, as expected.
when I hit resend verification email, it returns me to login, and there are no apparent errors or anything otherwise logged in debugbar.

if I attempt to create a new account same thing.
no confirmation code in users table.
and no e-mail
and no error.

I will be happy to share whatever may be helpful, I've gone over everything numerous times, and just not sure what I'm missing.

Any help is appreciated, Thank you.

Michael

Session is always null

I was rejected at login but the confirmation msg is always null.
confirmation_user_id I can get it normally.
use file session deiver
How can I do it?

session([
   'confirmation_user_id' => $user->getKey()
]);

throw ValidationException::withMessages([
  'confirmation' => [
    __('confirmation::confirmation.not_confirmed', [
        'resend_link' => route('auth.resend_confirmation')
      ])
   ]
]);

How should I replace the traits?

Sorry if this isn't an issue but I have trouble to make this package work! I also asked on stackoverflow but no one answered. How should I replace the traits? I mean what should I replace with what?

Instructions: vendor:publish has too many backslashes

Instructions say:

php artisan vendor:publish --provider=BeyondCode\\EmailConfirmation\\EmailConfirmationServiceProvider

Removing the escaping of backslashes in the command of course fixed it:

php artisan vendor:publish --provider=BeyondCode\EmailConfirmation\EmailConfirmationServiceProvider

Other than that it installed and worked like a dream - just what I was looking for :)

Laraval update

I cannot update Laravel to 5.7 it's might conflict with these codes.
Is it any way to update?

Migrations not published

Hi

The vendor publish command does not seem to generate a migration file currently.

php artisan vendor:publish --provider=BeyondCode\EmailConfirmation\EmailConfirmationServiceProvider

"Publishing complete."

php artisan migrate

"Nothing to migrate."

Thanks

Tom

Users can't login afer logout

Sometimes my users have this issue that when they logout, they can't login back again! They get "These credentials do not match our records." error while they are registered and confirmed their registration! I think this is something to do with sessions maybe. Did you ever had this problem? How can I solve it?

IDEA: Signed routes?

Laravel recently added Signed Routes. Is there a need to use a database table when we can just use them?

I can PR this if you want...

Quotes missing for the vendor:publish command

On macOS the vendor:publish command only works when the provider js enclosed in quotation marks:

php artisan vendor:publish --provider="BeyondCode\EmailConfirmation\EmailConfirmationServiceProvider"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.