From 91208e72862cf34d6bcbeaf59126b24c95906e11 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Fri, 18 Dec 2020 17:27:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20login=20and=20logout=20route?= =?UTF-8?q?=20for=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register is also handled by login --- server/routes/auth.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/routes/auth.js b/server/routes/auth.js index e69de29..70886f0 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -0,0 +1,17 @@ +const express = require('express'); +const router = express.Router(); +const passport = require('passport') + +router.get('/auth/login', passport.authenticate('local', {failureRedirect: '/login'}, + (req, res) => { + res.redirect('/'); + }) +); + +router.get('/auth/logout', (req, res) => { + req.logout(); + res.redirect('/login'); +}); + + +module.exports = router;