April 2020
Intermediate to advanced
716 pages
18h 55m
English
The API endpoint to sign-out a user is declared in the following route.
mern-skeleton/server/routes/auth.routes.js:
router.route('/auth/signout').get(authCtrl.signout)
When the Express app gets a GET request at '/auth/signout', it executes the signout controller function.
mern-skeleton/server/controllers/auth.controller.js:
const signout = (req, res) => { res.clearCookie("t") return res.status('200').json({ message: "signed out" })}
The signout function clears the response cookie containing the signed JWT. This is an optional endpoint and not really necessary for auth purposes if cookies are not used at all in the frontend.
With JWT, user state storage is the client's responsibility, and there are multiple options for client-side ...
Read now
Unlock full access