User Email Verification using nodemailer Mern-Auth Node js Mongodb express

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and welcome to my YouTube channel today we will see how to verify the email address using node mailer we have already created the sample authentication in the last video you will find the link in the bio at the beginning in the user model are the attribute verified of type Boolean which takes the value false by default then in the model folder created a new file token.ga in this file we will create the token model in which we will save a token for each user in this model we have to attribute the user ID as an object ID which content the ID of the user and the token attribute which contained a token of type string now we will generate the token so every time we create a new user a token will be generated so this token will take the user.id in user ID and it will generate a token using crypto thank you guys here we use crypto.random bites dot tostring to generate a random string so here if we register a token will be generated as you see in the database now in the utils.gs file we will create the very female function in which we will use node mailer this function takes two parameter email containing the user email and the link containing the token first we will create the transporter so that we can send email we start with the configuration what service do you use here I use Gmail then we will enter the authentification parameter user will continue email address so guys declare your parameter in the dot on file pass will content the password for your Gmail account now we are going to send the mail we use send mail so we are going to enter the content of the message from the sander is your email from you two the email the user email is the receiver subject is account verification we can add some text and in the HTML where we create the body of the message here I will drag some the link here I will just sum the link in the user router file declare the constant link will we create this path letter to activate the account as the link our localhost link slash API slash users slash confirm slash token dot token so we take the token from the model token now we are going to call the very familiar function you see guys it works successfully I will receive the mail now we create the function that allows us to activate the account in user router we create a new router so our path is confirm slash token so we found the token from the request.parameter.token and the token we will look for the user by IG by token.id then we will charge very few to true after we remove the token now in the login function the user must be verified to be able to connect foreign already sent by email verificate becomes true and the user is talking is deleted thank you guys for watching like And subscribe please
Info
Channel: Coding Easy
Views: 7,466
Rating: undefined out of 5
Keywords:
Id: KsLHiNHcUPE
Channel Id: undefined
Length: 13min 34sec (814 seconds)
Published: Tue Feb 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.