🔥 Access Source Code, PPT & Notes here for Free : https://www.thapatechnical.com/2024/11/introduction-to-nodejs.html ------------------------------------------------------------------------ In this video, I’ll show you how to create a complete Email Verification Page step by step. We’ll cover setting up the route, building the controller, and handling errors like undefined isEmailValid. By the end, you'll have a fully working verification page integrated into your app. Watch till the end and grab the free source code! 🚀 Boost Your Skills with these Pre-Requisite Videos:
⌛TIMELINE⏳ 0:00 🔹 Intro to Email Verification Page 0:12 🔹 Ensure Schema is Error-Free 0:52 🔹 Steps to Create the Email Verification Page 3:15 🔹 Access Source Code for Free 3:48 🔹 Creating the Email Verification Route 5:20 🔹 Setting Up the Controller for Email Verification 7:35 🔹 Building the Email Verification Page 12:00 🔹 Handling Undefined isEmailValid Error 13:00 🔹 Alternative for isEmailValid Value 14:30 🔹 Next Video Update
Hello what's up guys today in this video
we will see how to create a verify email
page in our application yes guys today's
video is very important because
what we are doing through out this series
basically for the last few days now we are
seeing how we can implement the process of email verification in which
we had seen in yesterday's video
how to create schema
and the schema of those people was not getting reflected properly
in the data studio of Drizzle basically
so I
also told you the solution in yesterday's video that how
you can delete the migration file and
create a new database and just do all those
steps again okay still I am saying that
even now if your that reflection is
not visible here in this way the table of email valid is not visible
inside users this
field of email valid is not visible
please comment please comment
I will try my best to help you all
okay while I am already in the video I have
already told you that there is only one session,
your work will be done very easily, make sure there is no error in the schema,
now the schema is ready, everything is ready, look
this is my profile page, whenever we
come to the profile page,
we will see some such data where
you can see one thing very clearly and that is
email verification is not verified, so there is a
button that is your verify now, so
when you click on this button, the page that you are
seeing is what we have to create in this video today, yes guys,
so this is
yours, if you look carefully, that is your
verify email page, which we are
doing in EGS,
which we get in Template Engine Express, so guys, in
this way our life becomes so easy,
where I am already telling you
what we are going to create in this video today, so now you
know, and there is
a lot in it, yes guys, it is
not created so easily, here we are using EGS,
and you know To
create anything, first we need to
create a route, then we need to create a
controller file. In that controller file, we have to
query all the data that is going to be used here and then
we have to fetch it and then we have to
render this particular file.
Once we pass this file to the render,
then we will create this file. It will have
all this data in it. There is a button,
an input field, then there is another button of verify code on it. If
I click this button, then
which function should it go to.
If I click on this button, then
which route should be hit. There is a lot
behind this, guys, which we will see in this video today. So
I have already done this, I did
a lot of trial and error, only then
I know now that it is going to happen in this way.
Else guys, no one gets to know so easily
on the spot, but I am going one by one
steps and I have already
made a video, it is very
important, very important that Is
this part verify email logic
I have made the whole logic clear with you
because once if we have an idea of logic
that okay first we have to do this then we have to do this
then we have to do this if not this then we have to do this
then we can do that work else
if you don't know the end goal
you just keep doing it let's do this then
maybe I will get to know that so there is a little bit of
trouble however you can do that also
like the first time scientist who is doing some
research he already
knows that I will get this much from the law here he is
doing trial and error
right but I have already done that trial and error from your side so
now this is the
part I have told the logic just
follow that logic try if you can
add something extra from your end also then so
alright now we start the video without any delay
before that the
source code is absolutely free there is no tension
you can easily get the complete steps
I have told and if you want to support
only For ₹199 you will get the
source code, notes, PPT, CPT of my entire YouTube videos.
Okay, and if you have
n't subscribed to the channel yet, please do so
because it helps me a lot.
And like the video and share it with friends. If you have
any doubt, please comment. Okay, alright.
So now let's go to
our code. Now we know
how our route is. So first of all, let's do one
thing. And if you see,
when I am clicking on Verify Now,
Verify Now, there is a route on
which I am redirecting him by resend verification, that
means we have already seen the profile page.
Okay, okay, here there is a Verify Now
button. And this is your Verify Now button.
So whenever anyone clicks on this for a second, okay, whenever someone
clicks on this, where does he go?
He is basically going to the Verify Email page.
But here, where are we
sending him? Resend verification, in this
way. You are sending them on this route, right? So now
we have to define it. Look carefully,
so auth dot route, here I go. So
it's your router dot route.
Okay, look here, resend very one second
here we have to send them dot get.
Here, guys, we name it Get Verify
Email Page. And let's do one thing, there is
Verify Email here, right? We also call it Verify
Email. And obviously
obviously don't worry, I would like to call it Verify Email here also. I
hope the concept is clear.
Whenever someone clicks on this Verify Now button, then
what are we doing on this route, we are
redirecting him. And if we
see the route, whenever someone hits this route,
he will go to the Get Verify Email
page. Basically, not this page, it's your
controller. Now, I will write my code inside this. The
code that we will have inside this will come at the
very bottom. Let's go to this place in this manner. And
I would like to go here. So,
look guys, it's not a big deal. Whenever you click
here If you come then we have request and then
response. Now here one thing is that if the
user does not exist, okay if there is
no
user
and a request dot user dot is email
valid if its value is true then it means
we will return a
response dot redirect them to their home page. You are
understanding simple what I am
trying to say, right? So here please
understand carefully this simple logic is happening where
if the value of request dot user is
anything, it means what will be its value
true and what is the not operator of true,
it will become false.
Okay and this part is by
default we are making it false.
We have kept this email valid by default as false. In
this way if both are false then it will never go
here, it will go below it,
so return response dot render and
what will I do here, my file which is
inside auth, this get, okay, basically this is the
name of my file, I would
like to redirect them there. I hope you understood,
one second the code is complete, friend this is it,
okay I will put a comma here,
you should pay attention to one thing, it is very important and that is
in this particular part,
believe it or not, I feel there are two things and that is
one is the email ID, here you can
see very clearly the email ID, here
you can see which user has logged in,
so one email ID is appearing in this page
and secondly I can do one thing where ah
you will get to know about it later but
right now at least I have to pass the email
request dot user dot email ah
email valid and guys I am thinking that let
us leave it for now, let us
leave it for now so you saw
how easy it is, we created our route, we
created a controller and in the controller
I said that brother whenever someone
hits this route, redirect it to this particular file
and that is your
verify email
views auth and or this is it, okay so auth
Inside this we are creating this
right and I have passed the email to this, okay
now I would like to paste my verify email
directly because this
code is very repetitive kind of
code, so I don't want your time to be
wasted, verify email and don't worry, I will
explain it to you very well line by line,
so no tension, look guys, I have
styled it, you will see your headers, then we have this
verify your email, this is your
verify your email, this you are locked
in, so I have told you 000 times, if the user exists then you are
locked in, if he doesn't,
else you are not locked in, it is a
simple if else statement in which
format is it okay, then
after that we are showing an email
inside the container, so to show the email, I
wrote a simple code of EGS, look here and
I showed the email, right, it was not a big deal,
then inside a paragraph we have written this simple thing
that your email has not Been
verified in this way, you
can resend and after that a paragraph and then we
have a button so we have this
paragraph and then you can see it's a
button but inside a form tag because it's
important that this is a form
whenever someone clicks on it what are we doing
inside the action this particular link is
there we are passing it to them on which
I am using the method which post and
then form inline and in this way
I have written guys inside the button so whenever you
write a button inside a form and if
you click and type that button if
you give submit it means whatever
action you have written in the form
whatever is your action attribute or property you can say it will be
read and redirected there
basically and we will tackle this particular route in tomorrow's
video that whenever someone is
going on this route then which
steps we will have to follow and I have already
told that email In the logic one,
method post is kept, pay attention to this, the
rest of our work is only this much here,
alright then after that if you see, there is
another container or section
in which there is an input field and then we have a
button and obviously in this also there will be the same
form, inside which there will be an input field, in
that input field obviously we need to enter two eight
digits, so the maximum
length required is given a pattern in
this way and there is a label
and we have kept a hidden field, don't
worry when the right time comes, I will tell you
why, but for now, as it is, just
keep it as it is and after that if you see, then we have
a button and by the way in this hidden field
also I have given a value
by email, okay, ignore it for now, for
now just ignore it, don't
take tension and then we have a
button in which there is verify code and then again
type submit, so inside any form, if
you have a button and if You type
submit it means whenever
someone clicks on that button, the action that you have given in your form tag will
go there and the method that is there,
that take it, I mean it will make sure
that which method has been called and which
route is being hit, so in the get method that
verify email token, so on one side with the
help of this button, when we basically
click on it, we generate a link, on
which we will click, then guys, one page
opens from Ethereal where I get
two options, eight digit
code and verify email, so on one side that
is there and the other is where you are verifying
that okay you have verified
but the eight digit that you have written is
equal or not, that email id is equal
or not, so that is happening here, one of its
work is till sharing the mail,
after that the work of verifying is this, the work of both these
buttons, okay so this much of our work is
done, I mean save control s,
I hope you understand There's not much in this, it will be more
fun than yesterday's video, when suddenly we start
implementing things,
I clear this, from here
I stop this which was
running earlier because only then you will know
what we are doing, npm run
and then deb oh my god I just realized that
we cannot log in, why because
in the video of day before yesterday I had
blown up the whole database, so we need to first do the
registration part, okay,
I write the password, okay and now we have
written the code in such a way that the moment I
register, by default it gets logged in
and if I go to the profile,
then you can see something like this,
I click on verify now
and ok, okay so here is the thing, when I am
clicking on verify now, I
actually shouldn't have come to this page,
I had to go to the verify email page, so
guys, you can see that we have
come back to the same page, whereas this shouldn't have happened
and I have There is a code, I will
show it to you guys for a second, yes just
check it out, let's check it out what it is
and oh my god, I realized what the
like response is doing, here the request should be request
dot user
and something like this, okay,
here I would like to go to
refresh profile verify now and boom
guys, our work is done, so now how
easily now you can see that at least
we are getting that if
both of these are false then
only do this, if even one of these is
true, it means our work is not done,
okay and sometimes this particular
part, guys, this
can also put you in trouble sometimes or can cause problems, so
I would like to quickly share another alternative to this with you
and that
is, look carefully because in whichever
way I want to know whether it is valid or not, then
we can do one thing, cost
user will be equal to a wait, right, our
whatever find user by id, this which This
is a particular method, we have already dealt with it
where request dot user dot id, I
can do this so if I go on this, this is
basically a function which
we are calling where we are
selecting from our users table and
if the id matches,
you give me the entire field data of the user, whatever
we are returning, basically okay
once it is returned, then it will get
all that data, by all the data
I mean this in which id, name, email,
password and is email valid where
you can see this, I will
get that then what will I do if I
can say another one that if the user is not there or if the
value of user eggmail valid is true,
then you return it to this particular
page and response dot redirect to
this particular home page this is it, if
you do this, you can remove it for the time being
then your work will become even better because
you are doing double secure I mean validation
here that brother Open this page only when
everything is validated, so according to me
this should work now and in a better way,
although I was doing it earlier as well, right ref
alright perfect see home profile verify
now and boom guys see so or this is it guys that's all
for this video today I hope you
liked the video very much
where we are seeing everything step by step
in tomorrow's video now we will
see when you click on the recent verification link,
how you can generate that eight digit token,
how you
can add data to the database, then how you
can share the mail through the nd mailer, there is a lot of
fun, so each and every video is very important every single day,
you cannot miss even one that's why
I am updating the source code regularly, I am
sharing it with you guys for free
so that you guys don't get down anywhere if you want to
support me, the
source code of the entire YouTube video is for ₹199 and guys If you
like the video then please like and if you don't like it then please
dislike and comment. If you have any
opinion or feedback regarding the video
or how I can do better then please
tell me by commenting and our
next target is 8 lakh people. If you have not
subscribed yet then please do. I will meet you
in tomorrow's video till then guys.
Thank you so much, take care
[Music]