Skip to content

Instantly share code, notes, and snippets.

@itwasmattgregg
Created October 22, 2022 21:24
Show Gist options
  • Save itwasmattgregg/70f0490267c09a79323af16cb152dc3b to your computer and use it in GitHub Desktop.
Save itwasmattgregg/70f0490267c09a79323af16cb152dc3b to your computer and use it in GitHub Desktop.
import { withSessionRoute } from '@utils/session';
export default withSessionRoute(async (req, res) => {
const user = req.session.get('user');
if (user) {
// in a real world application you might read the user id from the session and then do a database request
// to get more information on the user if needed
res.json({
isLoggedIn: true,
...user,
});
} else {
res.json({
isLoggedIn: false,
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment