Let's move on to our last big drought handler it is sign out to us instead of our routes directory.
We're going to find that file.
Open it up.
I'm going to delete the rest.
Send inside there.
We're going to add in some code to sign that user out.
So what does it really mean to sign out a user.
Well essentially we're going to send back a header that's going to tell the user's browser to dump all
the information inside that cookie just empty it out.
And that's going to remove the chase on a Web token.
That means any time the user makes a follow up request there will be no token included inside that cookie
to empty out all the information inside the user's cookie.
We're going to use the cookie session library once again because remember that is what is handling all
of our cookie related stuff.
I have the documentation for Cookie session already up on the screen right here.
And if I scroll down a little bit says very plainly to empty out a session and destroy all the information
side of it.
We'll set rect session equal to null.
That's pretty much it.
It's inside of our post request handler to sign out.
We will add in rect session is no.
And then naturally we do still have to send back a response.
So I'll just send back an empty object and I should be at.
All right well let's save this go back over to post man and do a quick test back inside of post man.
I still am looking at the tab where I'm making a get request to figure out the current user if I send
this off.
Looks like I'm not logged in right now so I'm gonna go back to my first tab where I have the request
configured to do a sign in attempt I've got my valid email and password so I'm gonna send that off and
now I should be logged in to confirm that.
I'll go back over to the get tab right here for current user Yep looks like I am now logged in.
Now finally do test out the log out functionality I'm going to open up yet another tab I'll make a post
request to age CPS Poland slash slash and then ticketing Dev API users and sign out
I'll go ahead and make sure I just set the header of content I application flash Jason and I'll go ahead
and send that now I get a response right here of empty object which is what we would expect if I now
go back over to the get request tab where I tried to get the current user I can send that off and you'll
see that I am now logged out.
All right well that's pretty much it for sign outs now as I mentioned at the end of the last video when
we finished working on current user we were going to extract some logic inside of here into two helper
middleware.
So let's take a pause right here and then start to tackle that in the next video.