In this video, we’ll learn how to verify user emails in Node.js with two different methods to make your app more secure. We’ll go step by step, from creating the email verification schema to using the isEmailValid field in multiple places in our app. Stay till the end to get the premium source code for free! 🚀
📌 Topics Covered: ✅ Complete demo of email verification (2 ways) ✅ Creating schema for email verification ✅ Using isEmailValid in the profile page & more ✅ Get free premium source code
-------------------------------------------------------------------- 🚀 Boost Your Skills with these Pre-Requisite Videos:
⌛TIMELINE⏳ 0:00 Intro to email verification 0:40 Complete Demo on how to verify email (2 ways) 7:00 Upcoming videos update 9:15 Have doubts? Ask in the comments 9:50 Get premium source code for free 11:02 Creating schema for email verification 14:25 Use isEmailValid in profile page 18:00 More places to use isEmailValid field in our app 21:15 Support by subscribing
Hello what's up guys, today in this we will see
schema for email verification, yes
guys, today's video is very important,
believe me, because here you can see
that in this particular project
we have completed the email verification,
however, this process, we are going to
see one by one in the upcoming videos, which is going to be
very important, but
one thing I would like to tell you today
in this video that today's video is very
important because I am
going to tell you the complete logic that what is the reason
behind the email verification that we are going to do,
okay, so look carefully,
first we will cover the theory, then there will be a
small code which we will see in this video today and then
we will see it piece
by piece step by step, day by day, so
guys, now look carefully, currently this is a
home page right and here we have our simple
database which we are doing in diesel and this is
our QRL short project, if I
go to my profile page, then you
can see Maybe that links
createddocumentsfragment
verification here you can see verified
right but I have
already verified that email I have received we have
seen a lot so now I will tell you that
if it is not verified then
what is the secret behind it and how will we deal with it
look carefully I will go to
my database so here we have a database
named user basically there is a table user
where there is id there is name email there is
password and there is an important field and that is
email is valid till now we have
not created it but today in this video
we are going to create this only this is the
schema for your email verification now now
we have to add a schema inside our user
here you can see two out of false
one of the value is true this one which is true is
currently this and that is
now when I come back to the profile and
boom guys see this is it this is what I want to
show you now see the real logic of
not verified and verify now
Have a button, now what is the logic, I will
tell you when you click on
verify now, you will come to a page, the
name of the page is verify email, listen carefully,
inside that you can see that here
we have given a button recent verification
link, when the user clicks on it,
we will get a link, we have to click on that link,
there will be token and then the
verify link part will be right and then our
verification will be done, but I tell you, let's see and see
now, okay, when I
click on this, I am going here
and boom guys, see what is visible,
you have got a link verify email
here, okay we are using there,
first we will
use there as AMTP server inside nut mailer, after that we will
tell you in another way, the
mail which will also come on your official g mail, we will
see all that, but right now it is
important for us to understand the basics, where I have got a link
control and then I will click in this way,
so I would like to
open it, so it opens in the moment So
you get an interface like this where you can
see click the link below to verify your
email in which you can use this token or you can
click on this particular anchor tag for basic link so
we will have two ways to verify the email,
one you copy a token of eight digits
or you can click on this, okay
I will copy it here,
here the CSS is a little messed up, don't worry
I will tackle it and when I click on the verify code,
okay what will happen,
look I click and boom guys
look it has been verified, right it has been verified
now if I go here which was
false now I will refresh it yes
and how to refresh,
you can see the result here so I
refresh it so look this has become true it
means that if the value here is true
then it gets verified and we do
not have to do anything manually, everything is
happening dynamic now I will go back here to this
I fall back, I would
like to come back to save changes and I
go back to home and come back to profile,
we can see this Verify Now, so
one thing is confirmed that there is a table, I mean there
is a field in our user table which is
very important and this is
yours, I mean and that is is your email valid
and this is the field that we need to create in this video today
because it is completely dependent on it whether
we want to
display the verified icon or not,
understand why today's video is important
and every video will now be important every day, you
understand every video will be important every day
if you are understanding it carefully,
now again I fell back
because I just showed that
when I copied and pasted that token,
then it got verified, what if I
just click on that link, okay
then I will go back to Verify Now,
remember this much, when I clicked on Verify Now,
I did not get any email I haven't received
any mail or it happens many times that
when we register then we get an email to
basically verify it, I mean it
comes on our G mail, do you understand what I am saying,
whenever you register in
general then the link to verify is sent to your mail,
then they say brother
verify the email, we will see that later, don't take tension
but for now if you understand
how the process is happening, life will become very easy,
until I don't click on it,
that link is not generated for me and
we are using it physically and that guy is for
testing purpose, that's why it is
visible to us on our console and that
's why I am opening the console and clicking on that link but
we will see everything later, I will
see again carefully this is
part here, okay now if I click
ok clicked, I will get a
mail in a while and I have got a mail, I will
click on open again, so
a while ago I showed you
how I copied the token and then I clicked on it
there I went and verified but
what if I click on this and
look carefully here is this what can I say
Raj Raj will be here and that is
alright see over here okay look at this this
part which is visible guys this part is
very important here because here we are
passing the token also here we are passing the mail also
and this is the same route which I am
calling when I was clicking on that button by
entering the eight digit token the
button on which I was clicking to verify,
we were calling this very route so
all these are connected with each other I know right
now you are able to match a little bit but the
reality is you have to click on that button and clicking
here is very easy because
there I was manually entering that eight digit character
and here if you and
perfect this is it look what token is visible
you are seeing the token here so I was
entering it manually there here I am
passing it on the URL itself and
requesting query I will get the data through it,
just simple, if I click on it,
boom guys I am verified,
so these are the two ways through which
we are going to track our email verification process,
but this is just a
trailer, next we will see how we can get
an actual
amazon.it token, then verify link, all these things
in your actual, we will also see that
log in with googleupdate.exe
mode or you can say hybrid authentication
since we have started, okay, I would
like to tell and that is refreshing
form validation, okay, from this place you
can say kind of session and
JWT authentication from here, this part,
you will not find it on my channel till date, so
this latest, whatever I am creating here,
you cannot miss even one of these, there would be very
few channels who would have created this and posted it for
free, okay and that's why guys
I am getting so much into theory these days
Because if you want to be a better
developer, then you must know the whole process.
Then you should code, at least you should
know the whole process.
What is the process of this website? Not at least
when you are creating an email,
you should already have an idea of the logic behind it. Then
you can code. It is not that you will keep coding and the
logic will come and it will work for someone.
But it is very rare. That is fine.
But I hope you must have understood. And one
thing that you must have understood very well is that
this particular part is email
validation
and verification. There is also email token.
Look here, user ID token and expire item. So
this part is very important which we will
see in tomorrow's video that now
we have to create this schema as well. And this schema is
used to verify email. And this schema that we are
creating, this schema we are creating
to make this particular field. We have to add an extra
field. That's it. So I hope
you understood the whole logic. What are we going to
see next and believe me this is just this much,
when you will see it next, we are going to do it even better,
okay but I want
you to sit comfortably and watch it every day, if you
want, you can investigate yourself
that how can I make it even better, I can
use something else instead of etherel, there is a
lot, okay so guys, now we
start the video without any delay,
but if you liked this theory part of mine
and you got to know what we are going to
see in the coming few days, then
please like the video and
share it with friends, if you have any doubt, then
definitely comment, if you do not
ask, then I will not be able to tell you
and I generally want you to ask such a doubt
that I also feel wow friend, now
force me to think, oh I did not even
think about this, you are not understanding and please subscribe because without subscribing,
then guys tell me where to get that motivation
because every single thing that I am making,
someone has also put it in my
mind for free I might not have put it in, brother, I
also have to work hard, behind this there is my team which is
creating content for us by working hard, so there is so
much, so guys, if
you think even this much for us, it will be a
very good thing for us, so please
subscribe, I will be very
happy and you should not have any problem in the source code,
so guys, for that we
already have the source code for you absolutely free, I have
kept it for you, so no tension,
you must check it out, here
you will get it of get hub, how
can you access, everything is there and if you want to
genuinely support, then guys, you can
get my entire youtube1 and all these things from here,
only and only 199, you
can check out by clicking here, okay, so
now we start the video without any delay,
so look, today
's video is very easy, so watch guys, first of all we go to
our page, the
page with schema, okay, so first of all it is
very important to go to the schema page because today
we have to add a field to our users
table So this is our user table, you
can see it very clearly, oh
here one second one second yes guys you
can see or this is it, look at this and
this is a user table and users there
we have kept the name of the user empty, there is
everything here, just one k and that is
email is valid, okay so I will create it now, let's
go under email or password,
is
email valid, okay and okay so what is this
guys, you see, it is either true or false, so
this is an integer, isn't it, this is your
variable character, this is a boolean
value, which value is it, it is a boolean value,
okay dot now here one thing you have to notice
whenever someone is logging in for the first time, okay okay,
whenever someone is
logging in for the first time, remember this much, the
value of this, if you must have seen a while ago, then
guys it was false, false, false,
okay so what we have to do,
it will have a default value which I would like to
set and that is false and it
should never be null, so not I am making it null.
Now this name is email
valid. So here it is
not like this, it is under email underscore
valid. So one thing is that guys,
what are we going to create in this way and if I
show you beforehand then your life becomes
so easy, right? That means, okay
friend, I have already seen this table. I mean,
I have done this. We are going to do this.
Now if we run it, then I will
not get this table. Basically, I will
not get this field. So, it will be easy for you guys.
What are we going to do? That is why
I try my best to
show you everything beforehand,
right? Alright, so is email valid.
Now remember this much, it is very important
when you are working in Diesel and that is,
when you change anything in the schema,
you know we need to generate and then we
need to migrate so that it gets
reflected in our database. And its
sequel becomes corresponding. Alright,
corresponding sequel. The code should be my
sequel, so make sure that this
balloon control and then space should be implemented on top, I mean it should be
imported,
so we have a balloon
value. Now there is not much change in it, it is
just that we have
added an extra feed to our user table.
I would like to run here. Now first of all,
before doing this, run npm one second. Ok, ok, npm run db
underscore we need to generate. Ok, I am
hitting enter.
Ok, so you can see that
they have made some changes in the users table. So
you can see that they have
added one thing. Ok, add this gmail valid
balloon default false not null. So, this has now been
added to our table, but now we
also have to reflect it, we will have to migrate it.
So, npm run db underscore
migrate. When you do this, then
it is actually reflected there.
See, the session table already exists,
but You don't have to
take tension here now I would like to go to this
place npm run db and then studio
so when you run this command then you
see this so here you are seeing it I will
refresh it once
let's check it out what happens so this
is a user and we have this much field over
here so guys right now you can see that
we are not able to see it but it's fine
but whatever it is we will tackle it but we have done
our work from our end okay
now this that you have created now
where all do you need it I will tell you to
see from the bottom so first of all now come to
our profile page okay if
you remember that what I am
showing you a while back basically
this will not work now your this is okay okay it is
still working very good okay so
this particular code that you are seeing
I want it now where I had
shown you if it was not verified then what would it
look like if it was verified then it would look something like this
So I need this code and it is
dependent on what, I will tell you to
look carefully, so this is a profile
where if you see, basically the links
created profile button is fine
and it is the last active in between them, so I have to
write that code here,
now guys I already have that code
and it's not that big, so I do
n't want to waste your time, I will
paste it, there is nothing, it's a
very simple logic and that is here,
first of all you will see the email verification,
you will see the email verification
and then here after that the value is
changing and it is dependent on what is
your email valid, so
whatever is inside the user's table through the user,
okay, this is inside our token,
basically the user is our token right now,
so here you can see that the user does
email is valid, so it means that we are
passing through our controller this
one field and on the basis of that field we are
deciding I mean If its value is
true then show verified which is
showing right now if it is false look else
not verified has been used remember we had
shown earlier not verified is shown in red color and then
you will see a button
basically an anchor tag is visible which says
verify now and when I was clicking on it
then I was getting a link
basically not link we were getting redirected to a page
and inside that page
I was seeing the resend button then so in
this way that's all the code and
this code that we have written is written in our ejs
ejs and we are working on that
our template engine is okay I will save the control and
now one thing here is that
inside this user this email I mean email is valid
property where did it come from there is no tension I would like to
go to auth data controller
look here carefully this is
get profile page okay and inside au there is
profile that means whenever someone clicks on this route
Basically, I will show you that
whenever someone goes to the profile page,
we are opening this get profile page controller,
there I found out the
entire user data through find user by id and I
also needed the short links table,
so I found that out as well.
Now this user has all the
tables of the user, we are getting their data very
easily, basically, the entire data of whichever id matched,
by complete data, I mean this
entire suppose which was the first id, so
I am getting this 11 id number 11 Vinod Bahadur
Thapar test, this entire data is coming to me,
but recently I
also created it by making is email valid, so it means that
I will go here, email not
email, whatever it is, is email valid, I will copy it and paste it
here and here
user dot is email valid,
I will pass it in this way, this is it, so in this way
we have passed it here and here
I am now using it in this way, I hope
you have understood till here, okay
now. One more thing is important here, now
I am removing it. I am removing it.
So I have used email valid at two places.
We have to use it at other places as well.
Like, I would like to use it on the auto controller.
Whenever we are creating an access token,
I would like to pass its value there as well.
Why am I doing that?
We will see that later. But for now, just
pay attention. When we are playing with the access token,
see the video of the authenticate user dry
principal. If you remember,
I have recently added the dry one, which you can see
by the way
or over here. See, two days ago,
in this video of implement drive principal, I showed how we have
created a function. And I have
come inside that function. Now, if you see,
this particular code, I would
like to add one more thing here. And that is by
default is
email valid. This property is what I am adding.
And here, by default,
I am keeping its value false. By
default, I have kept its value false here.
Okay, I copied this here,
I kept it here, I need it,
we can check out through access token also,
and one more place is very
important, th dot
a, this is basically verifying,
here we are talking about this, look at this one here also, so
if your access token expires, then
we can refresh both of them with the help of refresh token, that's
why I told you that you will just watch the video,
oh I understood, and after a week the
whole mess comes out, I don't know what happened here, so this will
not work, okay, so we
have this access token verify access token, we have this refresh token, so here you
look carefully, when I am talking about refresh token,
so refresh token here, look at
this, if I go on this, then here this user's
info is like this, so
what will I do in this user info,
I will paste this code, now here
we can do one thing, here this
user, if you look carefully, what am I doing? I am finding
from my database, so if I
talk about my database, then I am
getting all the data of everyone
through my database, so what can I do then,
here instead of false, I will
say that whatever value your email is valid,
whether it is false or true,
you can add it here, that is very important, on
one hand I am doing it manually
at this place and I did it manually at this place
because from where was the data
coming to me here, the user was not getting the data,
but yes, here I get the data
because when the access token is not expired, it
means once we have provided the access token to
him, we have to understand a little bit
here, okay,
I am passing it for my profile page
and on the profile page I am checking
out that if the
value of gmail valid is true then it is verified, if it is not, then
not verified and the verify email
button has to be shown, it is used at four places
and I did it in the schema Create So
ya guy this is it That's all for this video today Let
me know in the comment section Guy
how did you like today's video and then did
you understand the main logic or not
In tomorrow's video now we will create the actual schema
for verifying our email
I have already
shown you what all is required for that but tomorrow we will
understand it in depth but I hope guys
you liked today's video and
you must have understood the complete logic and
regarding whether your field of email is valid has been
created or not Let me know
in the comment section If it has not been created then
we will tackle it tomorrow you don't have to worry
but whatever I had to tell you in today's video
I have shared with you I hope you
liked the video very much So guys if you
liked the video then
please like and share it with friends our
next target is 8 lakh
subscribers If you haven't subscribed yet then
please do I will meet you in tomorrow's
video till then guys Thank you so much take
care
[music]