1
00:00:00,210 --> 00:00:05,970
All right, and once the middle of middleware is in place now, of course, we just need to decide where

2
00:00:05,970 --> 00:00:11,910
we're going to place it, because if you remember the previous project, we only had one authenticated

3
00:00:11,910 --> 00:00:12,270
route.

4
00:00:12,630 --> 00:00:15,060
And of course, we just use the water for that.

5
00:00:15,600 --> 00:00:19,080
And technically, we can do the same thing over here and jobs.

6
00:00:19,380 --> 00:00:25,180
But we just need to understand that, of course, in this case, we want to authenticate all the routes.

7
00:00:25,530 --> 00:00:31,740
So basically, we want to protect all of them, because if I create a job, I only want to look at my

8
00:00:31,740 --> 00:00:38,440
jobs and I don't want you to modify my jobs or you probably don't want me to modify yours.

9
00:00:38,790 --> 00:00:44,710
So essentially what I'm saying, we want to add that protected the route for all of them.

10
00:00:44,850 --> 00:00:50,310
So we want to protect all of our routes as far as the jobs, not just one of them.

11
00:00:50,650 --> 00:00:55,650
So technically, you can say, yeah, well, we can import and then we can just add them one by one.

12
00:00:56,070 --> 00:01:00,090
And technically it is an option, but there's actually a better one.

13
00:01:00,570 --> 00:01:03,030
If we go to objets, take a look.

14
00:01:03,390 --> 00:01:07,890
We have abductor's and then, of course, we have all the job roads.

15
00:01:08,130 --> 00:01:13,770
And in this scenario, what we can do can just get the middle middleware and then stick it in front

16
00:01:13,770 --> 00:01:14,540
of the jobs.

17
00:01:15,300 --> 00:01:19,920
And with that in place, all of our jobs routes will be protected.

18
00:01:20,160 --> 00:01:27,240
So instead of going one by one, we just do that in objets and as a result will protect all the job

19
00:01:27,240 --> 00:01:27,510
roads.

20
00:01:27,870 --> 00:01:28,610
So let's do it.

21
00:01:29,010 --> 00:01:30,900
We're going to go where we have the connect.

22
00:01:31,080 --> 00:01:33,270
And above or below, it doesn't really matter.

23
00:01:33,630 --> 00:01:38,980
I'll say authenticate user and we'll go with require.

24
00:01:39,060 --> 00:01:44,310
And of course, I'm looking for my middleware and in there I'm looking for authentication one.

25
00:01:44,700 --> 00:01:51,480
And then we scroll down, we go with authenticate user, pass the comma and we're good to go.

26
00:01:51,900 --> 00:01:58,440
And in order to test it, we'll go to the controllers over here and then we'll start working and create

27
00:01:58,440 --> 00:01:58,790
jobs.

28
00:01:58,800 --> 00:02:05,160
Anyway, I'll look for great job and we'll just start out and test it out in the following way where

29
00:02:05,160 --> 00:02:10,740
I'll go with not Jason and let's just pass here Eric, that user.

30
00:02:11,220 --> 00:02:15,570
So I'm getting that user from my office one if everything is correct.

31
00:02:15,900 --> 00:02:20,690
And of course, I should be able to see the user as well as the ID.

32
00:02:21,090 --> 00:02:22,470
So let me save it over here.

33
00:02:22,470 --> 00:02:29,850
And as a side note, I actually remove all my current users in the database just so we can start nicely

34
00:02:29,850 --> 00:02:35,310
from scratch, because as we were setting them up, we used the dummy string and then we set up the

35
00:02:35,310 --> 00:02:38,380
proper one just so we don't get any -- bugs.

36
00:02:38,400 --> 00:02:44,340
I also suggest to do the same one, remove all the users and start everything from scratch.

37
00:02:44,640 --> 00:02:46,950
So now of course, I want to go to the postman.

38
00:02:47,170 --> 00:02:49,260
I already have the register out.

39
00:02:49,260 --> 00:02:49,740
Correct.

40
00:02:50,010 --> 00:02:52,170
So let's just get the token first.

41
00:02:52,410 --> 00:02:56,010
So I of course, I go with name, email and password.

42
00:02:56,250 --> 00:02:57,990
I get the token sum.

43
00:02:58,320 --> 00:02:59,850
That's what I wanted.

44
00:03:00,150 --> 00:03:02,290
And of course, we want to set up a new route.

45
00:03:02,580 --> 00:03:06,330
Now, again, this is going to be a post trought to create a job.

46
00:03:06,630 --> 00:03:09,420
So let's go here, say a new route.

47
00:03:09,780 --> 00:03:13,410
We're looking for the post method and we use the same.

48
00:03:13,410 --> 00:03:14,430
You are, of course.

49
00:03:14,730 --> 00:03:22,230
And that if you remember, the difference was that for jobs, we just go forward slash and jobs.

50
00:03:22,560 --> 00:03:25,830
And if you want to double check, just go to abcess first.

51
00:03:26,340 --> 00:03:27,080
That's the path.

52
00:03:27,270 --> 00:03:30,870
Again, this is already part of our variable, the euro one.

53
00:03:31,080 --> 00:03:34,220
Then we have the jobs and then, of course, in the routes.

54
00:03:34,470 --> 00:03:37,860
As far as the post, well, that's going to be a route anyway.

55
00:03:37,920 --> 00:03:42,680
So that's going to be the focus now for getting the single job deleting and all that then of course,

56
00:03:42,680 --> 00:03:45,630
to pass in the route parameters as well.

57
00:03:45,630 --> 00:03:51,930
But for the post it's simply for slash, which just means that we go with the URL and then the jobs.

58
00:03:52,290 --> 00:03:58,860
Now we're really not concerned with a body because we're just testing whether our authentication works.

59
00:03:59,250 --> 00:04:03,270
But where we do need to get is authorization over here.

60
00:04:04,020 --> 00:04:04,620
My apologies.

61
00:04:04,710 --> 00:04:09,330
I'm actually looking for the headers and the reason why I'm showing you the authorization, because

62
00:04:09,750 --> 00:04:15,570
at the end of this project, or maybe in a few years, I'll show you how we can set this up dynamically

63
00:04:15,930 --> 00:04:22,170
so you don't have to every time just copy and paste the user token, because we need to understand that,

64
00:04:22,170 --> 00:04:24,780
of course, we can use multiple users.

65
00:04:24,780 --> 00:04:25,170
Correct.

66
00:04:25,380 --> 00:04:28,630
And you don't want to copy and paste every time that token.

67
00:04:28,800 --> 00:04:32,760
So I'll show you a dynamic way how we can set that up, but not yet.

68
00:04:33,060 --> 00:04:35,640
So let's go here where we have the headers again.

69
00:04:35,820 --> 00:04:39,080
We're looking for the authorization one on line.

70
00:04:39,090 --> 00:04:42,780
We want to go with Barer and we want to pass in the token.

71
00:04:43,170 --> 00:04:47,400
And once I send if everything is correct, check it out.

72
00:04:47,740 --> 00:04:53,130
I have the user I.D. which should match to whatever ID I have in the database.

73
00:04:53,340 --> 00:04:58,710
And of course, I'm not going to check value by value, but hopefully you understand the area where

74
00:04:58,830 --> 00:04:59,640
these ones should.

75
00:04:59,710 --> 00:05:06,100
Match this one and the one that I have more than a postman and I can clearly see the name.

76
00:05:06,460 --> 00:05:13,270
So what happens if I go with a different user, if I register this user instead?

77
00:05:14,310 --> 00:05:15,580
What's going on here?

78
00:05:15,580 --> 00:05:16,750
Again, the same secret.

79
00:05:17,020 --> 00:05:17,900
We can get different.

80
00:05:17,920 --> 00:05:21,880
OCHAN And now, of course, we should get different name correct.

81
00:05:22,240 --> 00:05:29,620
So in the jobs arm of the John Tolkan and I'll post the item one once I send.

82
00:05:29,620 --> 00:05:31,520
Of course now I get back down.

83
00:05:31,780 --> 00:05:39,670
So what that means in any of the job routes, I have an aside or John's idea or whichever token I'm

84
00:05:39,670 --> 00:05:46,390
getting and when it comes to any of these functionalities will only deal with the resources that are

85
00:05:46,540 --> 00:05:49,020
associated with a user.

86
00:05:49,390 --> 00:05:53,890
Hopefully we're on the same page and now, of course, we can start setting up the functionality.

