WEBVTT

00:03.640 --> 00:06.220
Hey, did everyone they share in this video?

00:06.220 --> 00:10.960
We are going to work on the methods previously we worked on to the pre which are the hooks.

00:10.960 --> 00:13.750
So I have added the hooks here as in the comments section as well.

00:13.750 --> 00:15.670
So user dot pre is actually hooks.

00:15.670 --> 00:17.650
Similarly, we have user dot post as well.

00:17.830 --> 00:23.290
Right now we don't have any strict necessity of having this post and everything, so we don't need to

00:23.290 --> 00:24.100
work on that.

00:24.100 --> 00:29.050
Now further down the road, a user dot methods is what we are going to use to define some of the methods.

00:29.050 --> 00:30.490
So let's go ahead and do that.

00:30.490 --> 00:35.980
We're going to go ahead and say the same user schema dot and yes, at this exact same time, if you

00:35.980 --> 00:39.430
were yelling at me, then you are absolutely paying a lot of attention.

00:39.430 --> 00:45.280
If not, then pay more attention, my friends, because I was writing this method right after exporting

00:45.280 --> 00:46.660
and this is not how it works.

00:46.660 --> 00:49.570
And I've seen people making this mistake, so please don't do this.

00:49.570 --> 00:51.820
Let's go ahead and move this up here.

00:51.820 --> 00:53.830
So this is where exactly it needs to go.

00:54.520 --> 00:56.500
So again, a little bit exercise.

00:56.500 --> 01:01.990
So what you need to do is just like we have these pre and post, we have these methods, make sure there

01:01.990 --> 01:05.530
is an SX here and you can write as many methods as you like.

01:05.560 --> 01:10.990
What we are writing here is to validate the passwords because obviously we need to compare the password

01:10.990 --> 01:14.350
from whatever the user has entered in their login field.

01:14.350 --> 01:19.750
And since we can actually make this a method because we have the existing password, we have the B script

01:19.750 --> 01:20.140
as well.

01:20.140 --> 01:22.660
So why not to just check the password as in the method?

01:22.660 --> 01:28.330
So somebody can just say user dot email, he can also say user validate password, something like that.

01:28.330 --> 01:40.990
So let's add a comment and we are going to say validate the password with passed on user password.

01:40.990 --> 01:46.390
So obviously we need something with what the user is now passing in and we need to take something from

01:46.390 --> 01:47.320
the database itself.

01:47.320 --> 01:48.400
So really simple.

01:48.490 --> 01:50.320
So how we are going to go ahead and do that?

01:50.320 --> 01:59.980
We are going to call this one as is password validated or we're going to call this one as validate password.

01:59.980 --> 02:02.830
Again, feel free to name it better in case you are going with that.

02:02.950 --> 02:07.990
This is going to be a sync because remember database is always on some another continent and it might

02:07.990 --> 02:08.950
take some time.

02:09.160 --> 02:14.020
We're going to have a simple function just like this and there we go.

02:14.020 --> 02:17.770
Now this function will take only one parameter which is passed password.

02:18.130 --> 02:25.960
Let's call this one as user password or user send password.

02:25.960 --> 02:26.950
I'm running out of the name.

02:27.130 --> 02:27.390
Okay.

02:27.400 --> 02:28.750
You can call this whatever you like.

02:28.750 --> 02:30.700
So this is the user sent password.

02:30.700 --> 02:35.830
So how we are going to kind of check this one again, we have already checked that that script actually

02:35.830 --> 02:37.180
does this job for us.

02:37.180 --> 02:42.880
So we're going to go ahead and say, Hey Bee script, please go ahead and compare the password.

02:42.880 --> 02:48.340
So the script is going to compare the password with let's go ahead and say that this is the password

02:48.340 --> 02:55.240
needs to become paired with user send a password and we can access the property by saying this dot password.

02:55.780 --> 02:56.590
There we go.

02:56.590 --> 02:59.080
Now, not only this, this is going to take some time.

02:59.080 --> 03:03.010
So we're going to say a wait and also we're going to go ahead and return this one.

03:03.010 --> 03:08.020
So what this will do again, we have seen that script compare returns you just to true and false as

03:08.020 --> 03:08.620
a value.

03:08.620 --> 03:10.570
So we don't have to worry on that part.

03:10.600 --> 03:12.640
You need to just pass on again.

03:12.790 --> 03:15.160
These fields doesn't really matter which one you pass on.

03:15.160 --> 03:17.350
First, there's not password or user sent password.

03:17.350 --> 03:18.520
This really means same.

03:18.700 --> 03:21.940
And all we got here is now a simple, true and false method.

03:21.940 --> 03:26.440
Whether the password are same and anybody can use whatever they are calling this user, for example.

03:26.950 --> 03:31.960
So just like they say, they start email to access my email, they can now say validate password which

03:31.960 --> 03:33.580
will give a true or false result.

03:33.910 --> 03:41.500
I usually like to pass on something like this is is validate password so something like this so that

03:41.500 --> 03:44.380
I know really that this is a true and false event.

03:44.380 --> 03:45.910
So I'm going to keep it like this.

03:45.910 --> 03:49.900
So let's keep it as lowercase is a validate password.

03:49.900 --> 03:51.820
Again, this is a horrible name.

03:52.150 --> 03:57.220
Let's go ahead and think for something different up here is validated password.

03:57.220 --> 04:02.740
So this seems okay for as of now is validated password again not really a big fan of the naming up here.

04:03.040 --> 04:06.220
But again, I really just want to give you the basic idea of that.

04:06.220 --> 04:08.260
Let's go ahead and catch up in the next video.
