1
00:00:00,640 --> 00:00:01,150
Beautiful.

2
00:00:01,430 --> 00:00:05,950
Once we have the structure in place, we'll start setting up the functionality.

3
00:00:06,160 --> 00:00:13,570
And first, I want you to work on these two controllers, get all users and get a single user.

4
00:00:13,930 --> 00:00:17,170
And this should be extremely, extremely familiar.

5
00:00:17,800 --> 00:00:24,340
Where in the get all users, I want you to get only the users, where the role is user.

6
00:00:24,730 --> 00:00:29,630
Now you can get all of them, but just remember how to work with options object.

7
00:00:29,650 --> 00:00:37,660
I suggest getting users where the role is user, and I also want you to remove the password from the

8
00:00:37,660 --> 00:00:45,340
response because remember, if we just get all the users will get all the keys with the values, I want

9
00:00:45,340 --> 00:00:48,310
you to jog your memory, how we can remove something from the response.

10
00:00:48,880 --> 00:00:52,510
And then as far as get all user, just send back all the users again.

11
00:00:52,510 --> 00:00:54,760
Eventually, this will be protected throughout.

12
00:00:55,450 --> 00:00:57,310
And as far as get single user.

13
00:00:58,260 --> 00:00:59,400
Let's get the user.

14
00:00:59,430 --> 00:01:04,200
Only one user whose I.D. matches the one that in the primes.

15
00:01:04,349 --> 00:01:06,230
Again, we want to remove the password.

16
00:01:06,240 --> 00:01:07,830
That's not something we want to send back.

17
00:01:08,310 --> 00:01:13,050
If there is no user maestro A4 or four, if there is a user.

18
00:01:13,260 --> 00:01:13,740
Awesome.

19
00:01:13,740 --> 00:01:16,710
Let's send back the user in response.

20
00:01:17,130 --> 00:01:17,510
All right.

21
00:01:17,520 --> 00:01:18,850
So let's start working on that.

22
00:01:18,890 --> 00:01:23,600
And first thing we need to do well, we need to get the imports correct.

23
00:01:23,610 --> 00:01:24,510
And I purposely didn't.

24
00:01:24,510 --> 00:01:28,850
Not that in the me because I wanted you to struggle.

25
00:01:29,160 --> 00:01:33,300
Let's go here with Konst user is equal to require.

26
00:01:34,230 --> 00:01:41,340
And we're looking for the model, some models, and we're specifically user when we want to get the

27
00:01:41,340 --> 00:01:42,930
status codes, at least I do.

28
00:01:43,290 --> 00:01:45,010
That's really preference.

29
00:01:45,040 --> 00:01:46,350
So status codes.

30
00:01:46,800 --> 00:01:48,780
And is going to be equal to require.

31
00:01:49,260 --> 00:01:50,490
It should be.

32
00:01:51,270 --> 00:01:58,530
And we're looking for status, status, hyphen codes and then the very end.

33
00:01:58,710 --> 00:02:04,630
I also want to get the customer because we'll be throwing some custom error.

34
00:02:05,220 --> 00:02:07,140
And that is equal to require.

35
00:02:07,890 --> 00:02:10,259
And then we're looking for two errors folder.

36
00:02:11,320 --> 00:02:17,170
And since we're exporting from the index, that's all we have to do now, getting all users.

37
00:02:17,890 --> 00:02:20,100
What is the method that we're going to find?

38
00:02:20,470 --> 00:02:20,830
Correct.

39
00:02:21,290 --> 00:02:25,270
The only gotcha is that we only want the users where role is user.

40
00:02:25,480 --> 00:02:26,620
How do we set that one up?

41
00:02:26,650 --> 00:02:27,010
Well.

42
00:02:27,960 --> 00:02:37,140
We go here with Konst users is equal to await user dot find, so I want to get all of them and I find

43
00:02:37,470 --> 00:02:39,750
only users where they were always user.

44
00:02:40,200 --> 00:02:41,480
So let's go here, Earl.

45
00:02:42,060 --> 00:02:43,980
I don't set it equal to user.

46
00:02:44,190 --> 00:02:45,510
So that's the first part.

47
00:02:45,930 --> 00:02:47,280
Now we're getting all the users.

48
00:02:47,880 --> 00:02:49,680
Now what about removing the password?

49
00:02:50,280 --> 00:02:51,380
How we can remove them all.

50
00:02:51,390 --> 00:02:52,410
We're going to use select.

51
00:02:52,800 --> 00:02:58,970
We can go here would select, then we just need to say, well, what property I want to remove and not

52
00:02:58,980 --> 00:02:59,370
do that.

53
00:02:59,370 --> 00:03:04,630
I go with negative passwords, so this just removes it from the response.

54
00:03:04,650 --> 00:03:12,990
And now the next line will go with that status, status and passing the status codes we'll be looking

55
00:03:12,990 --> 00:03:13,210
for.

56
00:03:13,230 --> 00:03:16,320
OK, and then we'll add Jason.

57
00:03:17,400 --> 00:03:23,040
And they're just say that we're sending back to users now, I'll test it once I set up the second one

58
00:03:23,190 --> 00:03:29,820
just so we don't have to jump back and forth as far as a single user ID is in the params.

59
00:03:30,210 --> 00:03:33,420
We already know that if you want, you can structure it.

60
00:03:33,660 --> 00:03:37,980
But since it's only like what, five letters in the code, I think I'm just going to leave it there.

61
00:03:38,790 --> 00:03:41,640
So let's remove this line of code the arrows that send one.

62
00:03:42,130 --> 00:03:49,470
And first, let's start by getting the user in this case would go with a one user find one.

63
00:03:50,560 --> 00:03:58,750
Very important, this is getting one user where I.D. is equal to wreck params and remember it.

64
00:03:59,590 --> 00:04:00,880
Man, same deal.

65
00:04:00,910 --> 00:04:05,680
I want to remove the password, so minus password in response.

66
00:04:06,190 --> 00:04:10,150
But we also are going to have a case where that usually doesn't exist.

67
00:04:10,840 --> 00:04:11,170
Correct.

68
00:04:11,350 --> 00:04:22,300
So let's go here with if no user, well, let's throw a 404 throw new crust down here and we're going

69
00:04:22,300 --> 00:04:23,100
to be looking for.

70
00:04:23,140 --> 00:04:24,760
Not founder.

71
00:04:25,330 --> 00:04:29,730
I will say no user with I.D..

72
00:04:30,220 --> 00:04:37,960
And then let's look for Rick Params and I.D. one eventually if we're good to go.

73
00:04:38,900 --> 00:04:43,520
There's no status, and, you know, this is going to be much faster because of the status status codes,

74
00:04:43,520 --> 00:04:43,970
OK?

75
00:04:44,210 --> 00:04:50,540
And then user instead of users and I would go back since they're both public routes, we can test them

76
00:04:50,540 --> 00:04:51,800
right away and our post.

77
00:04:52,610 --> 00:04:54,750
So let's go to get all users.

78
00:04:54,800 --> 00:04:57,620
Let's send we get back all the users.

79
00:04:57,620 --> 00:05:04,280
So these are only the users where the role is user since in my case, John is an admin.

80
00:05:04,670 --> 00:05:13,280
I can only see Susan and Peter, and if I want a single user, I just go here and grab the Susan one.

81
00:05:14,180 --> 00:05:19,090
I change it around to the Saudi Senate and get back to Susan.

82
00:05:19,100 --> 00:05:21,950
I still don't see the password, which is really, really good.

83
00:05:22,250 --> 00:05:28,190
And if I'll start passing in the wrong ideas, then I'll start getting the error responses.

84
00:05:28,670 --> 00:05:32,390
And with this in place, we're going to start setting up our authentication middleware.

