1
00:00:00,050 --> 00:00:00,410
All right.

2
00:00:00,410 --> 00:00:06,680
And up next, let's set up create user functionality, which is going to be extremely similar to create

3
00:00:06,680 --> 00:00:07,370
job.

4
00:00:07,610 --> 00:00:11,630
Of course, in this case, we're going to work with the user model.

5
00:00:11,630 --> 00:00:14,510
So first let's navigate to auth controller.

6
00:00:14,690 --> 00:00:17,750
We're looking for to imports.

7
00:00:17,780 --> 00:00:24,800
We want to grab the status codes since we're going to use them and also we want to grab the user.

8
00:00:25,130 --> 00:00:31,970
So let's go here and we're looking for models and the user model.

9
00:00:32,619 --> 00:00:34,790
Just make sure you add the JS.

10
00:00:34,810 --> 00:00:36,790
Then let's look for register.

11
00:00:36,790 --> 00:00:43,480
So this is where we are going to create the user and we're going to start by creating the variable.

12
00:00:43,480 --> 00:00:45,880
I'm going to call this user.

13
00:00:46,740 --> 00:00:48,900
This is going to be equal to a weight.

14
00:00:49,200 --> 00:00:51,090
We're looking for user dot.

15
00:00:51,120 --> 00:00:53,160
Then the method name is create.

16
00:00:53,160 --> 00:00:56,520
And essentially we want to pass in req dot body.

17
00:00:56,520 --> 00:01:00,570
And yes, of course there's going to be a validation layer.

18
00:01:00,570 --> 00:01:02,490
That's why I'm just passing here.

19
00:01:02,490 --> 00:01:10,230
Req.body since by the time the Req.body reaches the register, I already know that all the values are

20
00:01:10,230 --> 00:01:11,430
going to be correct.

21
00:01:11,640 --> 00:01:15,720
And then as far as the responses, first of all, let's go with status.

22
00:01:16,700 --> 00:01:20,560
Let's set up the status codes and we're looking for created.

23
00:01:20,570 --> 00:01:28,280
So this will be 201 then Json and we want to show the user with this in place.

24
00:01:28,280 --> 00:01:31,310
Now let's navigate to read me.

25
00:01:31,580 --> 00:01:36,620
And basically in order to speed this up, I just provided the Json you want to send.

26
00:01:36,710 --> 00:01:41,240
So name, email, password and rest of the cool stuff.

27
00:01:41,240 --> 00:01:43,130
So first let's copy this.

28
00:01:43,160 --> 00:01:44,990
Let's navigate back again.

29
00:01:44,990 --> 00:01:48,260
We're looking for register user for the body.

30
00:01:48,860 --> 00:01:51,320
Let's send and check it out.

31
00:01:51,350 --> 00:01:59,060
This is my user and all of the values and of course role by default is user and therefore I see it over

32
00:01:59,060 --> 00:02:02,150
here and also the very, very bottom.

33
00:02:02,150 --> 00:02:04,430
I have the ID as well.

34
00:02:04,430 --> 00:02:10,130
So this is the functionality to create our user in the database.

