1 00:00:01,050 --> 00:00:06,450 Let's move on to our last big drought handler it is sign out to us instead of our routes directory. 2 00:00:06,450 --> 00:00:07,380 We're going to find that file. 3 00:00:07,380 --> 00:00:08,190 Open it up. 4 00:00:08,230 --> 00:00:09,360 I'm going to delete the rest. 5 00:00:09,360 --> 00:00:10,540 Send inside there. 6 00:00:10,560 --> 00:00:12,660 We're going to add in some code to sign that user out. 7 00:00:13,020 --> 00:00:15,480 So what does it really mean to sign out a user. 8 00:00:15,480 --> 00:00:20,760 Well essentially we're going to send back a header that's going to tell the user's browser to dump all 9 00:00:20,760 --> 00:00:23,100 the information inside that cookie just empty it out. 10 00:00:23,440 --> 00:00:25,500 And that's going to remove the chase on a Web token. 11 00:00:25,500 --> 00:00:30,270 That means any time the user makes a follow up request there will be no token included inside that cookie 12 00:00:31,180 --> 00:00:33,820 to empty out all the information inside the user's cookie. 13 00:00:33,820 --> 00:00:38,290 We're going to use the cookie session library once again because remember that is what is handling all 14 00:00:38,290 --> 00:00:40,180 of our cookie related stuff. 15 00:00:40,240 --> 00:00:43,540 I have the documentation for Cookie session already up on the screen right here. 16 00:00:43,960 --> 00:00:50,290 And if I scroll down a little bit says very plainly to empty out a session and destroy all the information 17 00:00:50,290 --> 00:00:50,930 side of it. 18 00:00:51,010 --> 00:00:53,300 We'll set rect session equal to null. 19 00:00:53,380 --> 00:00:54,640 That's pretty much it. 20 00:00:54,830 --> 00:00:58,090 It's inside of our post request handler to sign out. 21 00:00:58,090 --> 00:01:01,970 We will add in rect session is no. 22 00:01:02,000 --> 00:01:05,170 And then naturally we do still have to send back a response. 23 00:01:05,170 --> 00:01:10,260 So I'll just send back an empty object and I should be at. 24 00:01:10,300 --> 00:01:17,250 All right well let's save this go back over to post man and do a quick test back inside of post man. 25 00:01:17,260 --> 00:01:22,570 I still am looking at the tab where I'm making a get request to figure out the current user if I send 26 00:01:22,570 --> 00:01:23,330 this off. 27 00:01:23,380 --> 00:01:30,280 Looks like I'm not logged in right now so I'm gonna go back to my first tab where I have the request 28 00:01:30,280 --> 00:01:36,860 configured to do a sign in attempt I've got my valid email and password so I'm gonna send that off and 29 00:01:37,040 --> 00:01:40,190 now I should be logged in to confirm that. 30 00:01:40,210 --> 00:01:46,310 I'll go back over to the get tab right here for current user Yep looks like I am now logged in. 31 00:01:46,400 --> 00:01:52,400 Now finally do test out the log out functionality I'm going to open up yet another tab I'll make a post 32 00:01:52,400 --> 00:02:05,290 request to age CPS Poland slash slash and then ticketing Dev API users and sign out 33 00:02:08,570 --> 00:02:19,320 I'll go ahead and make sure I just set the header of content I application flash Jason and I'll go ahead 34 00:02:19,320 --> 00:02:26,040 and send that now I get a response right here of empty object which is what we would expect if I now 35 00:02:26,040 --> 00:02:30,980 go back over to the get request tab where I tried to get the current user I can send that off and you'll 36 00:02:30,990 --> 00:02:33,260 see that I am now logged out. 37 00:02:33,260 --> 00:02:38,720 All right well that's pretty much it for sign outs now as I mentioned at the end of the last video when 38 00:02:38,720 --> 00:02:43,940 we finished working on current user we were going to extract some logic inside of here into two helper 39 00:02:44,000 --> 00:02:44,690 middleware. 40 00:02:45,080 --> 00:02:48,170 So let's take a pause right here and then start to tackle that in the next video.