1
00:00:00,270 --> 00:00:05,670
All right, so now we've got our off in place, but in order to test it, we actually need to set up

2
00:00:05,670 --> 00:00:06,600
some more routes.

3
00:00:06,960 --> 00:00:12,750
Since all our current routes are actually public routes, meaning by design, they're accessible by

4
00:00:12,750 --> 00:00:13,170
anyone.

5
00:00:13,560 --> 00:00:21,840
So let's change that and set up some user routes and there will be able to attach the authentication.

6
00:00:22,320 --> 00:00:24,990
So then we can start testing out whether our cookies work.

7
00:00:25,470 --> 00:00:31,110
And just like with off, I want to start with general structure, where I want you to create a user

8
00:00:31,110 --> 00:00:32,100
control or file.

9
00:00:33,080 --> 00:00:41,030
In the controllers, one set up five functions that our users get single use air show current user of

10
00:00:41,030 --> 00:00:43,520
that user update user password.

11
00:00:43,940 --> 00:00:46,880
As far as response, just go, it's something simple.

12
00:00:47,000 --> 00:00:51,080
So let's not send them, then I think I'm going to add the function names here.

13
00:00:51,590 --> 00:00:54,620
After that, we want to go with user roots file.

14
00:00:54,920 --> 00:00:58,220
So create that one in or out here.

15
00:00:58,760 --> 00:01:00,740
Empower all users for time.

16
00:01:00,740 --> 00:01:08,660
We can just set up one route to a forward slash, meaning this is going to be to the API version one

17
00:01:08,660 --> 00:01:14,990
users and stick that all users in there because there's little more info I want to give you before we

18
00:01:14,990 --> 00:01:17,070
set up those root and nine.

19
00:01:17,100 --> 00:01:23,350
We want to import user roots and I'm going to name it as user router address.

20
00:01:23,750 --> 00:01:30,140
And just like with Auth Add Middleware API version one instead of off, we're going to go with users

21
00:01:30,470 --> 00:01:33,140
and use their router so.

22
00:01:33,990 --> 00:01:41,910
And let's start working on that controllers, first thing I want to do is to create a file user controller.

23
00:01:41,930 --> 00:01:42,540
Yes.

24
00:01:42,570 --> 00:01:49,460
Then let's create those functions and we're just going to start here with cards to get all users.

25
00:01:49,880 --> 00:01:51,890
As I said, this is going to be an Ironman one.

26
00:01:52,310 --> 00:01:55,580
So I don't want a regular user to see all the users.

27
00:01:56,060 --> 00:01:57,860
We only want to admit it.

28
00:01:58,130 --> 00:01:58,670
See that.

29
00:01:59,120 --> 00:02:01,460
So go here, get all users.

30
00:02:01,460 --> 00:02:09,830
And like I said, just so we can speed this up so that all users are out or whatever string you want,

31
00:02:10,130 --> 00:02:11,300
it's copy and paste.

32
00:02:11,960 --> 00:02:13,310
I think one more time.

33
00:02:13,910 --> 00:02:19,580
So total should be five get and this is going to be single user.

34
00:02:20,690 --> 00:02:22,250
That single user.

35
00:02:23,360 --> 00:02:26,420
And I'll do the same thing over here, so get.

36
00:02:27,920 --> 00:02:29,920
Single user.

37
00:02:30,820 --> 00:02:33,310
I don't even want to go with show current user.

38
00:02:34,840 --> 00:02:35,830
Show current.

39
00:02:36,890 --> 00:02:39,530
User, I must do the same thing here.

40
00:02:40,750 --> 00:02:41,430
Show.

41
00:02:42,010 --> 00:02:43,180
Show current.

42
00:02:44,060 --> 00:02:50,930
And user al-Sadat, we want to go with update user and update user password, and this is going to make

43
00:02:50,930 --> 00:02:53,760
sense once we start setting up the functionality.

44
00:02:53,780 --> 00:02:58,160
I'll talk about why we have two separate ones, so let's say I'm that user.

45
00:02:58,820 --> 00:03:02,380
So as far as the update user, just update the name and email.

46
00:03:02,400 --> 00:03:08,240
But when it comes to password, we want to set up a separate group, so it's going to update user and

47
00:03:08,240 --> 00:03:08,780
password.

48
00:03:09,290 --> 00:03:13,100
So was there the same thing or here update user?

49
00:03:13,840 --> 00:03:14,530
Password.

50
00:03:15,230 --> 00:03:19,790
And when do we need to do we need to go with module that exports online?

51
00:03:19,810 --> 00:03:22,030
We're looking for the object, or at least that's my preference.

52
00:03:22,030 --> 00:03:29,170
So I set up the object and say, Get all users, get single or I'm sorry, I got carried away.

53
00:03:29,170 --> 00:03:36,760
That gets single user show current user, update user and update user password.

54
00:03:37,090 --> 00:03:38,440
All right, beautiful.

55
00:03:39,070 --> 00:03:40,330
Let's take this sucker.

56
00:03:40,570 --> 00:03:43,990
The entire object and so will be able to use it just in a second.

57
00:03:44,710 --> 00:03:47,830
And, you know, just the speed this one up as well.

58
00:03:48,700 --> 00:03:49,900
Why don't we do it this way?

59
00:03:50,760 --> 00:03:52,740
Where in the crowds?

60
00:03:53,280 --> 00:03:56,730
First, let's go to a author out or just take this whole thing.

61
00:03:57,270 --> 00:04:00,620
I won't just change it around, so create a new file.

62
00:04:01,650 --> 00:04:06,030
User wrote per user or user route.

63
00:04:06,180 --> 00:04:09,000
That's the one that I want with copy and paste.

64
00:04:09,360 --> 00:04:13,500
Make sure you change the controller because that's what I usually do.

65
00:04:13,500 --> 00:04:18,300
I have the correct functions, but then they're still coming from the controller, which is not what

66
00:04:18,300 --> 00:04:18,720
I want.

67
00:04:19,170 --> 00:04:24,480
So I'm just looking for this boilerplate code where I don't want to rate the router from scratch and

68
00:04:24,480 --> 00:04:24,930
all that.

69
00:04:25,500 --> 00:04:32,970
So let's say it for now, we want to go back to our controller or I'm sorry, user controller in my

70
00:04:32,970 --> 00:04:33,270
bag.

71
00:04:33,720 --> 00:04:34,770
Let's grab that object.

72
00:04:36,070 --> 00:04:37,450
When back in the user route.

73
00:04:38,610 --> 00:04:40,350
We want to pass this year.

74
00:04:41,130 --> 00:04:47,430
We're looking for user controller, so for expression to use their controller and then as far as the

75
00:04:47,520 --> 00:04:47,820
out.

76
00:04:48,810 --> 00:04:50,790
Let's start from scratch.

77
00:04:51,730 --> 00:05:00,760
So what I want to do is to set up a route to API version one users where we can get all the users.

78
00:05:01,000 --> 00:05:02,200
So that's going to be a get.

79
00:05:02,950 --> 00:05:05,740
We're going to go here with get forward slash.

80
00:05:06,680 --> 00:05:08,330
And you know what, my bad.

81
00:05:08,360 --> 00:05:13,190
So this should be broader, that rout run forward.

82
00:05:13,860 --> 00:05:16,430
That's what happens if you have two ways how to set it up.

83
00:05:16,430 --> 00:05:20,430
So of course, this one was just about not post-rock, except in this case.

84
00:05:20,450 --> 00:05:27,710
I want to go around there, not around, then get and then we'll go with get all users now.

85
00:05:27,710 --> 00:05:31,670
Eventually, we will add some more middleware because, like I said, there's two things.

86
00:05:32,150 --> 00:05:38,660
First, all the rules that will set up for the users will be authenticated.

87
00:05:39,170 --> 00:05:45,830
So you cannot just access publicly user information or update the user information or anything like

88
00:05:45,830 --> 00:05:46,100
that.

89
00:05:46,490 --> 00:05:52,310
So all of them will have the authentication middleware, but not only that.

90
00:05:53,230 --> 00:05:59,890
Some of them like getting all the users will have only accessible with admin privileges.

91
00:05:59,980 --> 00:06:01,300
That's why we have the rules.

92
00:06:01,780 --> 00:06:03,540
So hopefully that makes sense for the time being.

93
00:06:03,550 --> 00:06:04,930
Of course, there will be all public.

94
00:06:05,440 --> 00:06:07,580
We'll just test them out there or just add them up.

95
00:06:07,580 --> 00:06:12,640
But then eventually there will be only available if the user has logged in.

96
00:06:13,090 --> 00:06:17,740
So routed that route forward slash and get method.

97
00:06:18,160 --> 00:06:23,290
And we're looking for get all users, then I want to look for that specific user.

98
00:06:23,710 --> 00:06:30,850
If you remember something like this where we're going rather that route and we're looking for forward

99
00:06:30,850 --> 00:06:31,210
slash.

100
00:06:31,450 --> 00:06:37,600
This is going to be to the users and then we want to go with get function and we're going to be looking

101
00:06:37,600 --> 00:06:39,790
for get single user.

102
00:06:40,150 --> 00:06:46,300
That's the one that we're looking for when I want to go with show current user, but the placement is

103
00:06:46,300 --> 00:06:47,900
extremely, extremely important.

104
00:06:47,920 --> 00:06:48,310
Why?

105
00:06:49,090 --> 00:06:55,330
Because when it comes to this idea, it's actually going to match whatever we have 40 show current user.

106
00:06:55,670 --> 00:06:56,890
Now let me just showcase that.

107
00:06:56,900 --> 00:06:59,110
So let me move up above the.

108
00:06:59,830 --> 00:07:06,250
And we're going to go here with water that route and then we go with forward slash show.

109
00:07:06,460 --> 00:07:11,770
Me and I'll talk about why this throughout is very useful, but not for now.

110
00:07:12,010 --> 00:07:13,480
We'll talk about it once we set it up.

111
00:07:13,960 --> 00:07:20,260
For now, I just want to showcase that if this is going to be below the I.D. banner, essentially what

112
00:07:20,260 --> 00:07:22,450
happens if you're trying to hit this route?

113
00:07:22,960 --> 00:07:27,940
It's going to return a error when it's going to say, Well, I cannot find the I.D. Please keep that

114
00:07:27,940 --> 00:07:28,300
in mind.

115
00:07:28,300 --> 00:07:28,630
Where?

116
00:07:28,900 --> 00:07:35,170
Yes, of course we can set it up where we add here, maybe a user and then show me or something like

117
00:07:35,170 --> 00:07:35,500
that.

118
00:07:35,500 --> 00:07:40,840
But just in this general setup, you have this idea this is a parameter.

119
00:07:41,230 --> 00:07:46,990
And technically, if I pass here, show me whatever basically is going to be the name that's going to

120
00:07:46,990 --> 00:07:48,460
be treated as that ID.

121
00:07:48,730 --> 00:07:49,720
And that's not what I want.

122
00:07:49,730 --> 00:07:52,810
Therefore, it is going to be all the way in the bottom.

123
00:07:53,020 --> 00:07:58,210
Hopefully this is clearer and probably will test it out once we actually have some roots and all that.

124
00:07:58,210 --> 00:08:04,210
But just please understand that both of them actually point to the same one.

125
00:08:04,480 --> 00:08:06,550
Therefore, we need to go with this one first.

126
00:08:06,560 --> 00:08:07,690
So this is going to be show me.

127
00:08:08,260 --> 00:08:09,550
Express will get that route.

128
00:08:09,760 --> 00:08:10,960
It's going to say, Okay, show me.

129
00:08:11,320 --> 00:08:16,060
And then only if it can find anything bad and eventually will go to it.

130
00:08:16,690 --> 00:08:17,780
Hopefully, that makes sense.

131
00:08:17,800 --> 00:08:26,350
We're going to go with get and this is going to be a show current user and reach to update and update

132
00:08:26,350 --> 00:08:28,930
user are actually a postrouting.

133
00:08:28,940 --> 00:08:34,740
So in this case, we're going to go route or not route and going forward slash and we're going to go

134
00:08:34,870 --> 00:08:35,890
update user.

135
00:08:36,549 --> 00:08:41,590
Then we'll go with postrouting and we're looking for update user.

136
00:08:42,770 --> 00:08:43,720
I'm that user.

137
00:08:44,080 --> 00:08:45,010
Copy and paste.

138
00:08:45,460 --> 00:08:47,670
And this is going to be for two passwords.

139
00:08:47,800 --> 00:08:48,550
Password.

140
00:08:49,630 --> 00:08:50,680
And password here.

141
00:08:51,530 --> 00:08:53,350
That's going to be the controller again.

142
00:08:53,390 --> 00:08:54,080
Same deal.

143
00:08:55,010 --> 00:08:57,380
Notice how we're going right away, have the forwards correct.

144
00:08:58,040 --> 00:09:00,560
And then after here, we're looking for a parameter.

145
00:09:01,310 --> 00:09:06,860
So if we'll hit the road and if it's going to be placed after the Oni Express is going to be like,

146
00:09:06,860 --> 00:09:07,220
OK.

147
00:09:07,880 --> 00:09:12,980
So the idea that you're passing in is update user, password or update user or show me.

148
00:09:13,220 --> 00:09:14,510
But that's not the case again.

149
00:09:14,750 --> 00:09:20,930
Yes, there's multiple solutions for this we can add here, maybe a forward slash user or maybe even

150
00:09:20,930 --> 00:09:23,630
we can place them in admin, but that's not what I want.

151
00:09:24,200 --> 00:09:29,010
This is very, very important for me to show you when we want to navigate you app.

152
00:09:29,490 --> 00:09:31,610
Yes, very much the same deal.

153
00:09:32,100 --> 00:09:35,360
Copy and paste for user router.

154
00:09:35,840 --> 00:09:38,630
This is going to be user route.

155
00:09:39,170 --> 00:09:41,570
And then once we scroll down.

156
00:09:42,960 --> 00:09:47,430
The author set up users in this case.

157
00:09:48,090 --> 00:09:50,860
This is going to be a user outer.

