domingo, 28 de marzo de 2021

Laravel 8 Jetstream How to enable email verification

 Laravel's Jetstream email verification is not activated by default.


Notice I am using Laravel Homestead. Should you use any other development environment, you should be good to go. 


Follow these steps

1.- Open the /config/fortify.php file and comment out the email verification feature, so that:

    'features' => [
        Features::registration(),
        Features::resetPasswords(),
        Features::emailVerification(),
        Features::updateProfileInformation(),
        Features::updatePasswords(),
        Features::twoFactorAuthentication([
            'confirmPassword' => true,
        ]),
    ],

2.- Open the app/models/User.php file and enable the Email verification functionality by adding:

use Illuminate\Contracts\Auth\MustVerifyEmail;
...

class User extends Authenticatable implements MustVerifyEmail
{
   ...
}


3.- Enable your email service. For example, in Laravel homestead you already have mailhog installed. Inside your .env set your email settings:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=hello@yourapp.com
MAIL_FROM_NAME="${APP_NAME}"

4.- Now try to register a new user and make sure your email settings are correct. 

Once I've registered I get the following view:

Laravel 8 Jetstream How to enable email verification

If I open my mailhog client:

Laravel 8 Jetstream How to enable email verification

I get indeed the Laravel Jestream email verification message.


References

https://jetstream.laravel.com/2.x/features/registration.html#email-verification

https://stackoverflow.com/q/64127670/1883256

https://www.youtube.com/watch?v=vgf3rjvAzEY


No hay comentarios.:

Publicar un comentario

Dockerize Moodle application

Create the docker - com pose . y ml file to deploy a Mood le application , using N ginx as a webs erver , latest PHP , and ...