1
00:00:00,550 --> 00:00:09,550
In this video, we are going to hide the icons from not authorized user and show to the owner of the

2
00:00:09,550 --> 00:00:10,180
posts.

3
00:00:10,180 --> 00:00:13,150
So how are we going to implement that?

4
00:00:13,240 --> 00:00:17,560
Let's look at the logic first before we start to code.

5
00:00:17,710 --> 00:00:27,190
First of all, we have the log in user and then we have the post being displayed inside the template.

6
00:00:27,520 --> 00:00:36,340
And for the post we have the user who created this particular post and then we also have the log in

7
00:00:36,340 --> 00:00:37,840
user as that.

8
00:00:38,290 --> 00:00:39,970
So this is a flow.

9
00:00:40,000 --> 00:00:45,770
We are going to check the ID of the user who has logged in.

10
00:00:45,790 --> 00:00:54,460
If it is equal to the user ID inside the post in that way, that post belong to the user and we can

11
00:00:54,460 --> 00:00:57,380
show or hide the icon.

12
00:00:57,400 --> 00:01:00,100
So let's go ahead and then get it done.

13
00:01:00,100 --> 00:01:07,300
So let's get back to the post details, which is inside the post and post details.

14
00:01:07,630 --> 00:01:11,130
And this is the HTML element, so let me collapse it.

15
00:01:11,140 --> 00:01:14,650
So here we are going to make a check.

16
00:01:15,700 --> 00:01:16,360
Eve.

17
00:01:17,270 --> 00:01:18,320
Post.

18
00:01:19,440 --> 00:01:20,340
Dot.

19
00:01:21,480 --> 00:01:25,650
User Dut, and that's called ID.

20
00:01:26,720 --> 00:01:29,740
Is equal to the user off.

21
00:01:29,780 --> 00:01:38,560
Remember, that is what we pass as low cost inside our dot JS and this is what I'm referring to.

22
00:01:38,570 --> 00:01:46,220
This one represents the ID of the log in user, and we have this one inside the template because we

23
00:01:46,220 --> 00:01:47,930
pass to look cars.

24
00:01:47,930 --> 00:01:54,050
So let me copy the variable name here and make use of it as that.

25
00:01:54,260 --> 00:01:57,200
But let's convert everything to string.

26
00:01:57,200 --> 00:02:00,170
Can I be asked to string?

27
00:02:01,530 --> 00:02:04,020
Because we are making some comparison here.

28
00:02:04,050 --> 00:02:14,100
Likewise, the ID from the database adds that then let's bring the body here and I'm going to cut this

29
00:02:14,100 --> 00:02:16,680
one and place it inside here.

30
00:02:17,330 --> 00:02:18,060
All right.

31
00:02:18,060 --> 00:02:21,090
So let me remove this comment here for now.

32
00:02:22,140 --> 00:02:24,870
So let's close the edges.

33
00:02:24,900 --> 00:02:26,730
Goes like this.

34
00:02:27,820 --> 00:02:31,870
And down here also goes like this.

35
00:02:33,060 --> 00:02:36,180
Save it, and we'll be good to go.

36
00:02:36,210 --> 00:02:36,810
All right.

37
00:02:36,810 --> 00:02:38,070
So let's see.

38
00:02:40,460 --> 00:02:45,860
And let me go back again homepage and refresh the entire application.

39
00:02:46,040 --> 00:02:50,300
And this post was created by DOE, but not me.

40
00:02:50,330 --> 00:02:51,380
So let's see.

41
00:02:52,390 --> 00:02:57,940
Where we have this error, it simply means that there is something wrong with our syntax.

42
00:02:57,940 --> 00:03:02,170
So let's look through where it's supposed to be one dot.

43
00:03:02,170 --> 00:03:05,920
So save it and let's refresh it and let's see.

44
00:03:06,040 --> 00:03:14,200
And you can see that we don't have the icons for delete and update because this post does not belongs

45
00:03:14,200 --> 00:03:14,920
to me.

46
00:03:15,070 --> 00:03:21,520
But if I go ahead and log in and create a post, you can see that I will have the icons.

47
00:03:21,760 --> 00:03:25,270
Let's add the number to this page.

48
00:03:25,270 --> 00:03:29,050
So let's get back to the views and index.

49
00:03:29,050 --> 00:03:32,440
I'm going to copy the passwords for this one.

50
00:03:32,710 --> 00:03:37,150
And let me go to post details and number for this.

51
00:03:37,150 --> 00:03:43,900
I think we have it, but we mess up with the code, so let me use the right tag here.

52
00:03:44,020 --> 00:03:44,680
Okay.

53
00:03:44,710 --> 00:03:46,720
So I think it will fix that.

54
00:03:47,930 --> 00:03:49,290
And there you go.

55
00:03:49,310 --> 00:03:51,180
We have the number.

56
00:03:51,200 --> 00:03:57,770
But I think that the cases for that number have some impact on this HTML element.

57
00:03:57,770 --> 00:04:00,260
So let's fix that one in the next video.

