Hey did everyone that they share and welcome to another video.
In this video, we're going to see that how we can actually sign up a user, do some testing and basics
of it.
Now, I also fired up the MongoDB campus so that I can see you can just keep it empty and hit the connect
and it will connect to your local database.
So my t shirt store is there and obviously we have created just one model verifying our theory.
Again, the user's is being created, but right now we have nothing inside this.
DB Now let's go ahead and fire up our post when we have already seen and work through with the errors.
In case you want to check them again, you can go ahead and do that.
We'll be sending it into the form.
Now you can use the encoded form, you are encoded.
But again, we know that we have already got a great discussion on that.
Let's go ahead and add a simple root, not root a simple object.
Let's go ahead and say that, hey, I'm sending you the name.
The name is going to be simply let's just go ahead and send it as one.
And again, by the way, just to sideline again all the users who are successfully registered into the
test database or all the users who use successfully sign up or test the logins with usually they are
written on the big white board on in your office in case your team lead is actually working a little
bit hard in guiding your team, then I usually personally do this.
I write all the test users on the board, so anybody who is trying to test the sign up login use the
same credentials so it makes a little bit synchronous.
Again, this is what I personally do.
Maybe it might be helpful for you as well.
So let's go ahead and say I want to send the email as well.
And the email is going to be.
Simply one at the rate ae dev and let's go ahead and send a password also.
Password.
And this password is going to be simply a string of one, two, three, four, five.
Remember, we have a validator, but we haven't actually gracefully handled that validator yet.
Probably we'll do that later on.
But let's go ahead and see if we are able to get some error, response or not.
Let's go ahead and send this as a post request and it says, hey, name, email and password are required.
We are sending that.
But again, this is not the error we were expecting because in this route, in case this password was
smaller, our validator should kicked in and we should be getting the validator at a response there.
So notice here we are getting this error response.
So we probably we need to gracefully handle these validator setters and all of that will do that.
But this is it.
This is let's go ahead and try out with that with proper one, two, three, four, five, six.
This time.
Let's go ahead and sending this in the body in the raw.
And again, my bad, this should be in the JSON.
So let's test out the theory of one, two, three, four, five this time and comma, comma.
And why are you having a trouble?
Come on, give me some suggestions.
Colon expected.
I'm giving you a colon.
There you go.
Now you're happy.
So let's go ahead and try this one more time.
This is it.
This is nice.
We are getting the validator error as well.
That user validation failed photo secure URL path photo URL is required.
So again, this is creating a little bit of issue.
We don't have the photo required, so we need to worry on that part as well first.
So let's go back up here into the models and let's remove the photo part because the photo is optional.
As of now, yeah, we have made this as required.
We shouldn't be doing that as of now.
Let's go ahead and remove this and remove this required as true.
Okay.
So you can give me a photo and an ID in case you have that.
The photo itself is not a required parameter.
So let's go ahead and save this one.
Let's go ahead and get back and see what it is saying all wrong this time.
Let's go ahead and say send.
And it says user validation failed password should be at least six character and we are getting that
thing again.
These errors are nice, but definitely we can handle them a little bit better.
But as of now I think this is a great job done.
So let's go ahead and do that.
Okay, so let's go ahead and try one, two, three, four, five, six.
Let's go ahead and send this and notice we are getting success as true token is receiving your email,
everything is receiving your password is getting still received as an encrypted format.
We probably might want to not show the password here.
Let's go ahead and try that inside whenever we are sending the token.
So cookie token.
So before we send this user, we are going to add a field up here user although we have not selected
the user itself, but again, hey, we will figure it out later on.
Password is going to be undefined.
We don't want to send the password.
Let's save this one again.
Hopefully this user came into the database itself.
Let's refresh.
Not here.
Come on.
Here refresh and we got this data created nicely.
So but we are not happy with that.
Let's go ahead and delete that.
And that's exactly what testing is meant for.
Let's go ahead and save this one and send it again.
And this time we are not receiving the password.
So super happy that our small nice trick is still working up.
Although we have made this as selected, the response shouldn't be getting that will fail.
Figured it out.
No worries on that.
Okay.
So this is all getting token, but also what we can see in the cookies itself.
We are getting the token here as well.
So this is only read only cookie.
So everything is working fantastic.
Super happy with that.
We have a couple of more things to worry about.
Most importantly, what if somebody sends us a photo URL or selects a photo as well?
And on top of that, have you noticed here I cannot do the testing in the JSON format of the photos.
How am I supposed to do that?
So we need to create a simple temporary view.
We will be passing on these name, email and password from that view.
Remember I told you about the edges?
Yes, exactly.
We'll be sending the photo from there and we'll be testing it out.
Whether things get on to the cloud or not, how we are able to store that into DB or not.
And a little bit more on to that.
Let's go ahead and catch up in the next video.