1
00:00:00,870 --> 00:00:01,290
Nice.

2
00:00:01,800 --> 00:00:08,400
And while we're still working on off functionality, let's also knock out the logo road and just like

3
00:00:08,400 --> 00:00:09,180
the other two.

4
00:00:09,360 --> 00:00:11,070
It's going to be a public route.

5
00:00:11,460 --> 00:00:15,180
And when it comes to cookies, there are two things we need to do.

6
00:00:15,720 --> 00:00:22,740
So unlike the previous project, remember when we worked on the API, the jobs one meant take a look

7
00:00:22,740 --> 00:00:31,290
at the folder final fourth and then remember, we didn't even set up logout because essentially we send

8
00:00:31,290 --> 00:00:32,560
back token.

9
00:00:32,910 --> 00:00:33,660
No response.

10
00:00:34,290 --> 00:00:37,260
So good job for the frontend was just to remove the token.

11
00:00:37,800 --> 00:00:41,740
Now, in this case, it's a little bit different because we're sending back the cookie, correct?

12
00:00:41,760 --> 00:00:44,020
So there are two things that we need to deal with the cookie.

13
00:00:44,040 --> 00:00:52,290
First, we want to set the token cookie, the one that we're sending with our JWT equal to some kind

14
00:00:52,290 --> 00:00:53,010
of string value.

15
00:00:53,670 --> 00:00:59,400
So in this case, think empty string or whatever value that makes more sense to you.

16
00:00:59,720 --> 00:01:01,380
My case, I'm going to go with logout, I think.

17
00:01:01,980 --> 00:01:05,190
And the second is to set expires.

18
00:01:05,700 --> 00:01:06,780
There's something small.

19
00:01:07,320 --> 00:01:13,920
So maybe 10 seconds or my preference is to go with the current time and I'll show you the differences.

20
00:01:14,320 --> 00:01:16,290
So first, let's go back to our controller.

21
00:01:17,270 --> 00:01:22,220
And here we're looking for to log out round, which is right over here.

22
00:01:22,820 --> 00:01:23,810
What was the sidebar?

23
00:01:24,350 --> 00:01:27,200
And then like I said, we don't want to check anything.

24
00:01:27,530 --> 00:01:29,030
I mean, there's no really need for that.

25
00:01:29,060 --> 00:01:32,180
What we want is just to remove that cookie.

26
00:01:32,600 --> 00:01:34,970
And the way we do that, we go with a resort cookie.

27
00:01:35,390 --> 00:01:39,290
And if you want, of course, you can set it up as a separate function.

28
00:01:39,860 --> 00:01:44,600
But in my case, since we'll just use it here, I'll set it up directly in the controller.

29
00:01:44,600 --> 00:01:46,130
So go write that cookie.

30
00:01:46,580 --> 00:01:47,330
What is the name?

31
00:01:47,630 --> 00:01:48,410
It is token.

32
00:01:48,530 --> 00:01:48,890
Correct?

33
00:01:48,920 --> 00:01:49,220
Why?

34
00:01:49,250 --> 00:01:52,550
Well, because that's why we set it up over here with attached cookies.

35
00:01:52,640 --> 00:01:54,050
And you know what?

36
00:01:54,530 --> 00:01:56,330
Knowing my luck with Mint, just double check.

37
00:01:56,870 --> 00:01:57,830
Yep, it is.

38
00:01:57,830 --> 00:01:58,610
Token awesome.

39
00:01:59,090 --> 00:02:04,100
So once I set the name same name, then I need to come up with some kind of string value.

40
00:02:04,340 --> 00:02:06,800
Again, we can go here with a random.

41
00:02:07,370 --> 00:02:08,900
We can go here with empty string.

42
00:02:08,930 --> 00:02:10,180
We can go here with logout.

43
00:02:10,630 --> 00:02:12,050
That is really up to you.

44
00:02:12,380 --> 00:02:15,080
So we're not setting here the JWT.

45
00:02:15,800 --> 00:02:18,380
We're just saying that, yep, is the same token.

46
00:02:18,380 --> 00:02:22,670
But now the value is different because we really don't care since we will remove it.

47
00:02:22,670 --> 00:02:27,930
And second, anyway, when we want to pass in the options, we'll still go with the same one.

48
00:02:27,950 --> 00:02:29,660
The S&P only.

49
00:02:29,870 --> 00:02:31,310
So let's set that one up.

50
00:02:31,640 --> 00:02:35,690
So say true here and then we want to go with expires.

51
00:02:35,990 --> 00:02:38,840
And like I said, you're going to set it up to something small.

52
00:02:39,230 --> 00:02:41,810
For example, five seconds or 10 seconds or whatever.

53
00:02:42,290 --> 00:02:48,830
And the way you do that is like this one would go with expires one new date again when we go with the

54
00:02:48,830 --> 00:02:49,130
date.

55
00:02:49,530 --> 00:02:57,110
But now we invoke it and then remember, we need to add those milliseconds, essentially time in how

56
00:02:57,110 --> 00:02:58,190
long it's going to expire.

57
00:02:58,570 --> 00:03:04,400
If you want five seconds, just multiply five by a thousand, correct?

58
00:03:04,730 --> 00:03:05,780
You guessed it correctly.

59
00:03:06,170 --> 00:03:08,120
So we're going to go here with thousand.

60
00:03:08,660 --> 00:03:14,600
Now in the browser, you'll be able to see that you'll be able to refresh and you'll see that in five

61
00:03:14,630 --> 00:03:16,430
seconds, the cookie disappears.

62
00:03:17,090 --> 00:03:19,880
Now you're not going to be able to do that in a postman.

63
00:03:20,360 --> 00:03:24,920
So therefore, my option is to always send just an empty one.

64
00:03:25,340 --> 00:03:30,270
And sure, what that means is just to remove these five seconds and I'll show you the differences in

65
00:03:30,270 --> 00:03:30,680
the second.

66
00:03:31,100 --> 00:03:33,410
So let me go to the postman.

67
00:03:34,730 --> 00:03:37,610
And they're looking for a longer one.

68
00:03:37,850 --> 00:03:43,580
So first, let me save the logging years or so here, and then I'm looking for a log out user.

69
00:03:43,940 --> 00:03:48,740
I don't have to pass anything I just send doesn't seem like we're getting anywhere.

70
00:03:49,340 --> 00:03:52,260
So log out here, log out exporting, OK.

71
00:03:52,580 --> 00:03:55,550
And of course, since I'm not responding and I think my apologies.

72
00:03:55,970 --> 00:04:01,400
Now, as far as the logging, you don't have to really sending things back.

73
00:04:02,090 --> 00:04:07,760
I mean, again, this is going to be the case where the front end sees two hundred and it's like, OK,

74
00:04:07,940 --> 00:04:08,780
everything is fine.

75
00:04:09,140 --> 00:04:10,970
But just while we're testing.

76
00:04:11,210 --> 00:04:12,950
Let me have the status code as well.

77
00:04:12,950 --> 00:04:17,560
Meaning let me add some kind of message in JSON so that discard you would still send back.

78
00:04:17,990 --> 00:04:20,740
What I'm trying to say is you can simply do something like this, right?

79
00:04:20,760 --> 00:04:22,550
Not signed and whatever.

80
00:04:23,000 --> 00:04:23,450
Correct.

81
00:04:23,600 --> 00:04:24,770
Because it doesn't really matter.

82
00:04:24,770 --> 00:04:27,380
As long as you send 200, we're in good shape.

83
00:04:27,380 --> 00:04:29,690
But I just be more precise.

84
00:04:29,690 --> 00:04:34,550
And let's say it has that status than let's set up a status code.

85
00:04:35,210 --> 00:04:36,230
Go with OK.

86
00:04:36,530 --> 00:04:41,330
And then, like I said, just for development purposes, I also like to have that message.

87
00:04:41,330 --> 00:04:44,930
So then I can clearly see what is happening while I'm working on application.

88
00:04:44,930 --> 00:04:48,020
But in general, frontend is not going to use this.

89
00:04:48,110 --> 00:04:53,660
So we're going to go with user logged out and exclamation point.

90
00:04:54,110 --> 00:04:55,790
And let's have it now.

91
00:04:55,790 --> 00:04:57,290
Let's go back to our post.

92
00:04:57,880 --> 00:05:04,630
Unless the set out so we have log out or out and such send out or something interesting.

93
00:05:04,640 --> 00:05:09,020
So I still have the cookies, but the value is the log out.

94
00:05:09,470 --> 00:05:11,210
And here we have expires.

95
00:05:11,630 --> 00:05:16,550
But the thing is, with postman, there's really no way for us to refresh this, but we can do it in

96
00:05:16,550 --> 00:05:17,150
a browser.

97
00:05:17,270 --> 00:05:20,750
If you go here to application and if you have cookies, you can refresh it here.

98
00:05:21,230 --> 00:05:26,290
So let's say if you have a cookie, you can refresh and just double check what is happening and then

99
00:05:26,300 --> 00:05:28,010
where you'll be able to see those five seconds.

100
00:05:28,340 --> 00:05:31,070
Now that's not what is happening in the postman.

101
00:05:31,520 --> 00:05:37,220
So actually, my preference is following where in my applications that have gone for at least five seconds

102
00:05:37,220 --> 00:05:41,300
or whatever, I just remove, I go with current time.

103
00:05:41,660 --> 00:05:47,360
And then when you'll notice that once we send the log out, then essentially we won't get back to cookie.

104
00:05:47,720 --> 00:05:51,770
And what happens if I go right now and check it over here?

105
00:05:52,770 --> 00:05:58,710
You know, coming out once I son, if you take a look at the console, there won't be nothing there.

106
00:05:59,170 --> 00:06:04,110
So there is no cookie, so we have successfully a moment now technically you're going to add those five

107
00:06:04,110 --> 00:06:09,240
seconds, wait for them in the postman and then send and you'll get back the same result.

108
00:06:09,250 --> 00:06:12,000
But it's always my preference just to remove the cookie.

109
00:06:12,270 --> 00:06:17,970
Essentially, what we're doing, we're moving cookie from the browser, sending back, log out and learn

110
00:06:18,240 --> 00:06:20,490
in here just for development purposes.

111
00:06:20,490 --> 00:06:22,420
We're adding also this user logged out.

112
00:06:22,420 --> 00:06:29,340
So then I can clearly see OK user has logged out over here in the body and just like that.

113
00:06:29,640 --> 00:06:32,160
We also have log out functionality.

