Laravel Breeze Reset Password with Email or Username

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends welcome so in the previous video we have customized the priest package when we login to login with either username or email and in this video I'm going to also change when we forgot your the password at either the email or username and also when we resetting the password the use either the email or the password so I'm going to use the mail trap for the mail sender so if you go and create new account let's copy this so on the inbox you can search select the level on the drop down copy the code and let's open the dot EnV file and replace the mail with that so the mill Miller host Port username password and the encryption okay then we need to change also the the forgot password plate the use emailer username so let's do that let's open the forgot password plate and here on the email address I'm going to say email or username and it's going to be the same we had in the previous video or the login so let's select all the emails here and replace with the input type in here I'm going to say username so email slash username the input type is going to be a text and for the errors we need to say email here and copy and paste for the username okay and let's say he username in here good let's close this and let's open the out routes so for the forgot password we have this password reset link controller and we have the create method which written in that view and then we have the store method which is validating the image we need to add also the username here and then it's going to send a reset link and add in the request only the email but we need add email or username and one area directly with status with input also here we need to add email or username and the same down there so let's start by creating here a variable so don't assign and I'm waiting emit the input type and I'm going to assign this with filter bar and I'm going to add the request we have the request in here so request input and the name of the input is input type and I'm going to check for the to validate for the email so let's say filter validate email and if that is true I'm going to say email otherwise username so if this string it's going to be username then we need to merge the input type with the request input so sorry let's say a request okay and merge ordinary DOTA sign input type the variable we created with the request input input type like this okay and now for the validation the same thing we had done in the previous video the image is going to be required without the username so if we have username it's not going to be required it's going to be email and also I'm going to add the exists in the users table and the email column and I'm going to copy this one and paste down there for the username the username now is going to be required without the email so if we have email we are not requiring the username it's going to be text sorry it's going to be string and if we exist if this exists in the users username good also here we need to add either the username or email and for that I'm going to add plus sign input type variable we created the same in here and also here and let's try let's open the browser and the refresh first we have email our username in the mail we don't have any so let's try and add so in the table plus we have this chondo user with username jondo and the email john.com so let's copy the username and come here go to paste and remove one's letter and let's say email password reset link yeah the selected username is invalid and the same I'm going to do for the email I'm going to copy that come here let's paste and remove one letter here and the selected mail is invalid okay let's add the correct one and let's say email password reset link and now it's going to send the email we have email to password reset link come here and yeah we have that and if we click we navigate that this reset Dash password the token and also we have the email here now it's up to you if you like I don't like that I'm going to remove because we are going to have either the email or the username here okay so with that now first we need to change this reset password uh plate and change to this that email or username and then the controller so let's open uh for the reset password is this new password controller and let's open that and here we have the create method okay then we have the store method which is going to validate the token the email and the password but we are going to validate the token the email or username and then send the password reset request only the email or username and down there the same thing when we have the email we need to change that so let's create the variable input type the same we have done in the previous controller and let's assign with a filter bar add here the request input and the name is going to be input type as well here and add the filter validate email if that is true is going to be email otherwise is going to be username and then we need to add that variables so let's merge a request merge add an array add the input type variable we created and merge with request input input type like this okay and now validate the email and the email is going to be required without the username or we can use is there sometimes so let's say I'm going to say here sometimes is going to be required email and also add if this exists in the users email like this I'm going to copy that and paste down there for the username sometimes required is going to be string and existing the users username like this okay well then also here request only when we have the email I'm going to add the input type variable we created the same in here request so the input type and in here the input type okay I think we are okay so we added here and let's see now close this one and let's delete the email and let's try one more time to send with username okay let's come here and I'm going to close this let's come here and open reset the password and we have the username we need to change this order uh blade so let's open the reset password blade and here I'm going to say email or username select all email values and replace with input type in the value I'm going to say email or username type is going to be text and here is going to be email or username so let's copy and say username here okay refresh and yeah we have username or email or username now also I want to remove this ROM here and if you go to the novel.com documentation on the password we have password customization and here on the reset link customization we can just add this line in the out service provider so let's copy and do that also and then we can test so I'll service provider on the boot method paste that line we need to import the reset password Plus also change the link to or link here copy and paste it here so STP custombreeze.test slash reset password and for the we need to say slash and the token like this because if I open the out s we have the get reset password slash token not question token people with the token okay for that we just say that like this and let's see one more time because in the email right now we have the question mark email with the email and let's delete this and send one more time with a username or just yeah that's user username okay and now yeah we have only the token and if I click reset password we navigate here we don't have the email now if you like you can do that if you don't like you can leave us it is at the username here toonto and I'm with it so the password we have in here I'm going to copy the hash and let's open the Big Crypt online and I'm going to have verify here add the hash in here and password here and I'm going to say verify as yeah it's must now we have password let's change that to something else let's say one to eight but first i'm going to check for validation on my username I'm going to remove that and let's say reset password and the selected username is invalid let's check for uh email yeah the selected email is invalid and now let's add the correct username and say one to eight I want it again and let's say reset password and now we have bin reset the password and if I type John Doe with the new password wanted login yeah we have logged in and if I copy here the hash now if I refresh and let's copy the hash paste it here refresh also here and let's go to the free fire and paste one to eight verify and yeah we have changed that and that's it how we can also add the username when we have forgot the password and we when we update the password okay friends that's it about this video I hope you enjoy and don't forget if you like like the video and subscribe to my Channel all the best and see you in the next video
Info
Channel: Code With Tony
Views: 3,591
Rating: undefined out of 5
Keywords: laravel 10, laravel tut, laravel tutorial, laravel auth, laravel breeze, laravel custom auth, laravel customize authentication, laravel custom breeze, laravel tutorial for beginners, web dev, vuejs, laravel authentication system, laravel 10 tutorial, laravel customize breeze, laravel custom login, laravel login with username, username, laravel breeze customize, laravel auth custom, laravel with username, laravel forgot password
Id: ZyUNGtAJ4ck
Channel Id: undefined
Length: 16min 17sec (977 seconds)
Published: Tue Feb 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.