WEBVTT

00:03.820 --> 00:06.670
Hey did everyone that they share and welcome to another video.

00:06.700 --> 00:11.980
In this video, we're going to see that how we can actually sign up a user, do some testing and basics

00:11.980 --> 00:12.550
of it.

00:12.580 --> 00:18.580
Now, I also fired up the MongoDB campus so that I can see you can just keep it empty and hit the connect

00:18.580 --> 00:20.380
and it will connect to your local database.

00:20.380 --> 00:24.790
So my t shirt store is there and obviously we have created just one model verifying our theory.

00:24.790 --> 00:29.080
Again, the user's is being created, but right now we have nothing inside this.

00:29.080 --> 00:33.790
DB Now let's go ahead and fire up our post when we have already seen and work through with the errors.

00:33.790 --> 00:36.280
In case you want to check them again, you can go ahead and do that.

00:36.280 --> 00:38.140
We'll be sending it into the form.

00:38.140 --> 00:40.480
Now you can use the encoded form, you are encoded.

00:40.480 --> 00:43.390
But again, we know that we have already got a great discussion on that.

00:43.570 --> 00:48.220
Let's go ahead and add a simple root, not root a simple object.

00:48.220 --> 00:50.860
Let's go ahead and say that, hey, I'm sending you the name.

00:51.340 --> 00:55.720
The name is going to be simply let's just go ahead and send it as one.

00:56.560 --> 01:01.360
And again, by the way, just to sideline again all the users who are successfully registered into the

01:01.360 --> 01:06.730
test database or all the users who use successfully sign up or test the logins with usually they are

01:06.730 --> 01:12.970
written on the big white board on in your office in case your team lead is actually working a little

01:12.970 --> 01:15.910
bit hard in guiding your team, then I usually personally do this.

01:15.910 --> 01:20.860
I write all the test users on the board, so anybody who is trying to test the sign up login use the

01:20.860 --> 01:23.200
same credentials so it makes a little bit synchronous.

01:23.200 --> 01:24.880
Again, this is what I personally do.

01:24.910 --> 01:26.740
Maybe it might be helpful for you as well.

01:26.890 --> 01:29.830
So let's go ahead and say I want to send the email as well.

01:30.580 --> 01:32.920
And the email is going to be.

01:34.700 --> 01:40.520
Simply one at the rate ae dev and let's go ahead and send a password also.

01:42.550 --> 01:44.260
Password.

01:44.680 --> 01:48.450
And this password is going to be simply a string of one, two, three, four, five.

01:48.460 --> 01:53.500
Remember, we have a validator, but we haven't actually gracefully handled that validator yet.

01:53.680 --> 01:54.850
Probably we'll do that later on.

01:54.850 --> 01:58.780
But let's go ahead and see if we are able to get some error, response or not.

01:58.780 --> 02:05.110
Let's go ahead and send this as a post request and it says, hey, name, email and password are required.

02:05.110 --> 02:06.370
We are sending that.

02:06.610 --> 02:13.840
But again, this is not the error we were expecting because in this route, in case this password was

02:13.840 --> 02:19.450
smaller, our validator should kicked in and we should be getting the validator at a response there.

02:19.450 --> 02:22.510
So notice here we are getting this error response.

02:22.510 --> 02:28.060
So we probably we need to gracefully handle these validator setters and all of that will do that.

02:28.060 --> 02:29.080
But this is it.

02:29.080 --> 02:32.830
This is let's go ahead and try out with that with proper one, two, three, four, five, six.

02:32.830 --> 02:33.550
This time.

02:33.760 --> 02:36.970
Let's go ahead and sending this in the body in the raw.

02:36.970 --> 02:39.280
And again, my bad, this should be in the JSON.

02:39.280 --> 02:44.740
So let's test out the theory of one, two, three, four, five this time and comma, comma.

02:44.740 --> 02:46.450
And why are you having a trouble?

02:48.160 --> 02:50.130
Come on, give me some suggestions.

02:50.140 --> 02:51.370
Colon expected.

02:51.400 --> 02:52.660
I'm giving you a colon.

02:53.380 --> 02:53.990
There you go.

02:54.010 --> 02:55.050
Now you're happy.

02:55.060 --> 02:57.530
So let's go ahead and try this one more time.

02:57.820 --> 02:58.440
This is it.

02:58.450 --> 02:59.020
This is nice.

02:59.020 --> 03:01.030
We are getting the validator error as well.

03:01.030 --> 03:06.190
That user validation failed photo secure URL path photo URL is required.

03:06.550 --> 03:08.740
So again, this is creating a little bit of issue.

03:08.740 --> 03:13.600
We don't have the photo required, so we need to worry on that part as well first.

03:13.600 --> 03:21.250
So let's go back up here into the models and let's remove the photo part because the photo is optional.

03:21.250 --> 03:24.070
As of now, yeah, we have made this as required.

03:24.070 --> 03:25.840
We shouldn't be doing that as of now.

03:25.840 --> 03:30.250
Let's go ahead and remove this and remove this required as true.

03:31.380 --> 03:31.680
Okay.

03:32.170 --> 03:36.460
So you can give me a photo and an ID in case you have that.

03:36.460 --> 03:39.880
The photo itself is not a required parameter.

03:40.120 --> 03:41.800
So let's go ahead and save this one.

03:41.800 --> 03:45.640
Let's go ahead and get back and see what it is saying all wrong this time.

03:45.640 --> 03:47.410
Let's go ahead and say send.

03:47.800 --> 03:52.120
And it says user validation failed password should be at least six character and we are getting that

03:52.120 --> 03:52.780
thing again.

03:52.930 --> 03:56.080
These errors are nice, but definitely we can handle them a little bit better.

03:56.080 --> 03:58.660
But as of now I think this is a great job done.

03:58.660 --> 03:59.950
So let's go ahead and do that.

04:00.280 --> 04:02.890
Okay, so let's go ahead and try one, two, three, four, five, six.

04:02.890 --> 04:08.650
Let's go ahead and send this and notice we are getting success as true token is receiving your email,

04:08.830 --> 04:13.480
everything is receiving your password is getting still received as an encrypted format.

04:13.480 --> 04:16.780
We probably might want to not show the password here.

04:16.810 --> 04:21.400
Let's go ahead and try that inside whenever we are sending the token.

04:21.400 --> 04:22.510
So cookie token.

04:22.510 --> 04:30.820
So before we send this user, we are going to add a field up here user although we have not selected

04:30.820 --> 04:35.110
the user itself, but again, hey, we will figure it out later on.

04:35.110 --> 04:37.780
Password is going to be undefined.

04:38.020 --> 04:39.430
We don't want to send the password.

04:39.430 --> 04:41.140
Let's save this one again.

04:41.140 --> 04:43.600
Hopefully this user came into the database itself.

04:43.600 --> 04:44.650
Let's refresh.

04:44.920 --> 04:45.640
Not here.

04:45.640 --> 04:46.270
Come on.

04:47.580 --> 04:51.600
Here refresh and we got this data created nicely.

04:51.600 --> 04:53.070
So but we are not happy with that.

04:53.070 --> 04:54.330
Let's go ahead and delete that.

04:54.330 --> 04:56.520
And that's exactly what testing is meant for.

04:57.450 --> 05:00.150
Let's go ahead and save this one and send it again.

05:00.390 --> 05:02.610
And this time we are not receiving the password.

05:02.610 --> 05:05.790
So super happy that our small nice trick is still working up.

05:05.820 --> 05:10.930
Although we have made this as selected, the response shouldn't be getting that will fail.

05:11.010 --> 05:11.640
Figured it out.

05:11.640 --> 05:12.630
No worries on that.

05:12.810 --> 05:13.060
Okay.

05:13.110 --> 05:16.710
So this is all getting token, but also what we can see in the cookies itself.

05:16.710 --> 05:18.720
We are getting the token here as well.

05:18.720 --> 05:20.280
So this is only read only cookie.

05:20.280 --> 05:22.080
So everything is working fantastic.

05:22.080 --> 05:23.280
Super happy with that.

05:23.790 --> 05:25.950
We have a couple of more things to worry about.

05:26.160 --> 05:31.920
Most importantly, what if somebody sends us a photo URL or selects a photo as well?

05:32.130 --> 05:37.680
And on top of that, have you noticed here I cannot do the testing in the JSON format of the photos.

05:37.680 --> 05:39.240
How am I supposed to do that?

05:39.240 --> 05:41.910
So we need to create a simple temporary view.

05:41.940 --> 05:44.940
We will be passing on these name, email and password from that view.

05:44.940 --> 05:46.680
Remember I told you about the edges?

05:46.680 --> 05:47.640
Yes, exactly.

05:47.640 --> 05:50.370
We'll be sending the photo from there and we'll be testing it out.

05:50.370 --> 05:54.780
Whether things get on to the cloud or not, how we are able to store that into DB or not.

05:55.020 --> 05:56.430
And a little bit more on to that.

05:56.430 --> 05:58.320
Let's go ahead and catch up in the next video.
