1
00:00:00,350 --> 00:00:03,800
And once we can successfully authenticate the user.

2
00:00:03,830 --> 00:00:09,590
Now let's also set up the logout functionality, which actually is going to be the last controller in

3
00:00:09,590 --> 00:00:10,640
the auth controller.

4
00:00:10,640 --> 00:00:12,800
So first let's navigate over there.

5
00:00:13,360 --> 00:00:15,850
Yes, we right away want to export it.

6
00:00:15,970 --> 00:00:17,490
We want to go with log out.

7
00:00:17,500 --> 00:00:20,650
That's going to be the name of our controller.

8
00:00:20,890 --> 00:00:28,000
And effectively, when it comes to functionality, well, first, I guess let's start by setting up

9
00:00:28,000 --> 00:00:28,910
our function.

10
00:00:28,930 --> 00:00:31,780
It's still going to be looking for req and res.

11
00:00:32,640 --> 00:00:40,560
And then here, what's interesting, we want to go with red dot cookie and we want to create the same

12
00:00:40,590 --> 00:00:41,630
token cookie.

13
00:00:41,640 --> 00:00:44,480
So yes, names must match.

14
00:00:44,490 --> 00:00:47,330
And as far as the value, here's the deal.

15
00:00:47,340 --> 00:00:49,410
We're not going to pass in the same token.

16
00:00:49,410 --> 00:00:51,840
So you can leave it empty if you want.

17
00:00:51,840 --> 00:00:54,410
But in my case, I'm just going to go with logout.

18
00:00:54,420 --> 00:00:57,510
So essentially this is the value that we're sending back right now.

19
00:00:57,510 --> 00:01:01,140
Again, it's totally irrelevant what we place over here.

20
00:01:01,140 --> 00:01:06,420
What's important again, we're going to go with Http only and we'll set it equal to true.

21
00:01:06,720 --> 00:01:13,230
And as far as the logout, we'll set expiration to the current time.

22
00:01:13,230 --> 00:01:15,810
So essentially it will right away expire.

23
00:01:15,810 --> 00:01:17,340
And yes, that's how you.

24
00:01:18,010 --> 00:01:20,410
Set up the expiration for cookies.

25
00:01:20,440 --> 00:01:27,370
We go with expires then new date and unlike previously where we added that one day we simply want to

26
00:01:27,370 --> 00:01:28,570
go with date.

27
00:01:29,500 --> 00:01:32,260
Dot and now and we just invoke it.

28
00:01:32,260 --> 00:01:32,680
That's it.

29
00:01:32,680 --> 00:01:34,000
That's all we have to do.

30
00:01:34,000 --> 00:01:42,670
And then when it comes to response again, since we'll be sending back a cookie which right away expires,

31
00:01:42,670 --> 00:01:49,000
it's not really that important what we have in the Json, but in my case I will provide a message.

32
00:01:49,000 --> 00:01:52,930
So we go here with the rest dot status.

33
00:01:53,320 --> 00:01:57,910
We're looking for status codes and we'll set it equal to.

34
00:01:57,910 --> 00:01:58,540
Okay.

35
00:01:59,490 --> 00:02:00,180
Then.

36
00:02:00,180 --> 00:02:04,440
Jason And then we want to go with message and then user.

37
00:02:05,300 --> 00:02:06,980
Logged out.

38
00:02:08,070 --> 00:02:10,889
Then we want to navigate to routes.

39
00:02:11,650 --> 00:02:15,280
All throats and it's not going to be a post.

40
00:02:15,430 --> 00:02:18,910
So copy and paste is going to be a get route.

41
00:02:18,940 --> 00:02:22,210
The URL is going to be logout.

42
00:02:23,240 --> 00:02:25,670
And we're not going to validate anything.

43
00:02:26,650 --> 00:02:27,610
We're good over here.

44
00:02:27,610 --> 00:02:31,540
And of course, we simply want to grab the log on one.

45
00:02:32,320 --> 00:02:33,190
Let's import.

46
00:02:33,220 --> 00:02:34,040
Let's save it.

47
00:02:34,060 --> 00:02:36,880
Now we want to navigate to a thunder client.

48
00:02:37,240 --> 00:02:39,640
It's under the auth routes.

49
00:02:41,090 --> 00:02:42,230
Let's guess.

50
00:02:42,260 --> 00:02:43,580
Duplicate over here.

51
00:02:44,570 --> 00:02:46,160
I'll right away rename it.

52
00:02:46,580 --> 00:02:50,870
I just need to remember that it's a get root, so log out.

53
00:02:51,560 --> 00:02:52,370
User.

54
00:02:53,590 --> 00:02:54,070
Good.

55
00:02:54,070 --> 00:02:56,860
So the URL stays almost the same.

56
00:02:57,040 --> 00:02:59,200
Of course, in here we just want to change it to logout.

57
00:02:59,230 --> 00:03:01,900
It's not a post one, it's a guest one.

58
00:03:01,900 --> 00:03:05,260
We're not sending anything from the front end.

59
00:03:05,560 --> 00:03:08,830
We just want to send over here and notice.

60
00:03:08,920 --> 00:03:13,050
And as far as this token cookie, it immediately expires.

61
00:03:13,060 --> 00:03:22,030
So as a result, if I go back to get all jobs, check it out, I'll have authentication invalid.

62
00:03:22,330 --> 00:03:25,720
And with this in place, we can move on to the next step.

