And once we can successfully authenticate the user.
Now let's also set up the logout functionality, which actually is going to be the last controller in
the auth controller.
So first let's navigate over there.
Yes, we right away want to export it.
We want to go with log out.
That's going to be the name of our controller.
And effectively, when it comes to functionality, well, first, I guess let's start by setting up
our function.
It's still going to be looking for req and res.
And then here, what's interesting, we want to go with red dot cookie and we want to create the same
token cookie.
So yes, names must match.
And as far as the value, here's the deal.
We're not going to pass in the same token.
So you can leave it empty if you want.
But in my case, I'm just going to go with logout.
So essentially this is the value that we're sending back right now.
Again, it's totally irrelevant what we place over here.
What's important again, we're going to go with Http only and we'll set it equal to true.
And as far as the logout, we'll set expiration to the current time.
So essentially it will right away expire.
And yes, that's how you.
Set up the expiration for cookies.
We go with expires then new date and unlike previously where we added that one day we simply want to
go with date.
Dot and now and we just invoke it.
That's it.
That's all we have to do.
And then when it comes to response again, since we'll be sending back a cookie which right away expires,
it's not really that important what we have in the Json, but in my case I will provide a message.
So we go here with the rest dot status.
We're looking for status codes and we'll set it equal to.
Okay.
Then.
Jason And then we want to go with message and then user.
Logged out.
Then we want to navigate to routes.
All throats and it's not going to be a post.
So copy and paste is going to be a get route.
The URL is going to be logout.
And we're not going to validate anything.
We're good over here.
And of course, we simply want to grab the log on one.
Let's import.
Let's save it.
Now we want to navigate to a thunder client.
It's under the auth routes.
Let's guess.
Duplicate over here.
I'll right away rename it.
I just need to remember that it's a get root, so log out.
User.
Good.
So the URL stays almost the same.
Of course, in here we just want to change it to logout.
It's not a post one, it's a guest one.
We're not sending anything from the front end.
We just want to send over here and notice.
And as far as this token cookie, it immediately expires.
So as a result, if I go back to get all jobs, check it out, I'll have authentication invalid.
And with this in place, we can move on to the next step.