Email Verification For Laravel 8 Multi Guards Authentication

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome to our channel last days we created this video tutorial about laravel 8 multi-guards authentication today we are going to make email verification process on this multi-guards authentication [Music] as you can see i opened laravel multiguard's project in visual studio code let's show how this works now click here to register new user enter new user details as you can see we have this success message that show us that user registered successfully by looking in users table we see that user is now inserted into database let's login by using this user email and password as you can see we can go to this user dashboard in this video we are going to ask registered user to verify email in order to complete registration before everything let's show you how to enable less secure on your gmail account that will help you to send email via gmail smtp first thing you have to do is to allow your gmail account for sending email just click on manage your account button click on security link then scroll down and find less secure app access section as you can see my account less secure is off to turn on click on this blue link then change this toggle button position to blue color as you can see the less secure access turned on automatically google send notification about this updates so let's continue back to your laravel project.nbc file and update your mail variables after updating this save this file re-enter php artisan serve command for running your application back to users table and add new table column and rename to email underscore verified then set this value equal to zero by default and click save as you can see email underscore verified column has been added to this users table copy this column name and add this to user model fiable array open new terminal and run php artisan make colon model verify user dash m command as you can see verify user model has been created so add the following on this model file and go to create verify users migration file and update this verify underscore users table columns then run php artisan migrate command as you can see verify underscore users table has been created create new middleware by entering php artisan make colon middleware is user verify email command in terminal as you can see our middleware file has been created remember to add auth facade on this file inside this handle method let's add this condition if logged user email is not verified means not equal to one automatically log out and redirect this user to login page with info message let's register this middleware in kernel.php file let's apply this middleware to user roots simply add this on this middleware group add new get root for verifying user let's create verify method inside user controller class but before add that method we need to import verify user model here now inside this function let's verify user according to the requested token if this user email underscore verified value is equal to zero set this equal to one let's display info and verified email sessions on user login form now back to create method and update it like this generate token this last underscore id will help us to make desired unique token value according to the registered id then send email verification link to this registered user let's change this success message let's create this email template blade file i already have this responsive email template i'm going to use this template for this tutorial just copy this html markup and paste into this email template blade file because of our message contains html tags we need to echo this body variable like this let's test register new user as you can see we have this success message that ask us to verify account let's check our email as you can see we have new email friends we received this responsive html email with verify button let's click on this verify email button to verify our account now our email verified successfully enter password and click login button as you can see our account has been verified and we can login to user dashboard by looking to users table we see that registered user with email underscore verified equal to one and verify underscore users table store that registered user id and token suppose you already verify your account and try to click on this verify email button as you can see we have this message that shows me that my account had been already verified let's register another user as you can see new user registered and not verified if we try to login by using registered email and password we see this error message that show us to confirm account let's see in our gmail as you can see we received new email click this verify email button to verify this account as you can see email underscore verified became to one enter password and click login button as you can see we are now in user dashboard friends we finished email verification process for normal users we are going to apply the same process on doctors let's show you doctors register and login process before applying email verification let's register new doctor as you can see new doctor has been registered successfully let's login by using this dr credentials as you can see we are on doctor dashboard we are going to apply email verification on dr auth process add email underscore verified column on doctors table and set this default value to zero copy this column name and add this to dr model feeble array create new model by entering php artisan make colon model verify dr dash m command in terminal as you can see verify doctor model has been created update this model like this go to create verify doctor migration file and update this verify underscore doctors table columns then run php artisan migrate command as you can see verify underscore doctors table has been created create new middleware by entering php artisan make colon middleware is dr verify email command in terminal as you can see our middleware file has been created don't forget to import auth facade on this file inside this handle function let's add this if statement if logged doctor email not verified log out and redirect this doctor to login page let's register this middleware in kernel.php file let's use this middleware to doctors roots just use this middleware to this middleware root group add new get root for verify doctor account let's add verify method inside doctor controller class before write this verify method don't forget to import verify doctor model on this doctor controller verify doctor according to requested token update doctor login blade file then after update doctor create function this last id will help us to make desired unique token according to registered doctor then send email to registered doctor email address change this success message before test change this to action link let's test register new doctor as you can see we need to confirm account from the link send to our email address as you can see we received new email and this doctor account not verified let's verify our email by clicking this button as you can see this doctor account became verified now enter password for login as you can see we are in doctor dashboard by clicking on verify email button again while we already verified our account we get this message let's register another doctor friends that is how you can make email verification for laravel 8 multi guards authentication system thanks for watching this video you
Info
Channel: Irebe Library
Views: 452
Rating: undefined out of 5
Keywords: irebe library, laravel 8 tutorial, authentication, auth, email verification, laravel auth
Id: yrOkoXtioHE
Channel Id: undefined
Length: 36min 1sec (2161 seconds)
Published: Sun Dec 05 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.