From 54677c68f50b7c105a1f6cc5e9593877781fc8d6 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sat, 10 Jul 2021 22:57:13 +0200 Subject: Implemented JWT authentication using Passport.js --- server/routes/api.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'server/routes') diff --git a/server/routes/api.js b/server/routes/api.js index 3684aa0..a0890a7 100644 --- a/server/routes/api.js +++ b/server/routes/api.js @@ -1,8 +1,13 @@ const express = require('express'); const router = express.Router(); +const passport = require('passport'); const exampleController = require('../controllers/example'); +const userController = require('../controllers/user'); router.get('/', exampleController.index); +router.get('/protected', passport.authenticate('jwt', {session: false}), exampleController.index); +router.post('/register', userController.register); +router.post('/login', userController.login); module.exports = router; -- cgit v1.2.3