aboutsummaryrefslogtreecommitdiff
path: root/server/routes
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-07-10 22:57:13 +0200
committerMateja <mail@matejamaric.com>2021-07-10 22:57:13 +0200
commit54677c68f50b7c105a1f6cc5e9593877781fc8d6 (patch)
tree8998a76fdd76ca1170dc89cbf70423aeaf0efb0c /server/routes
parentfd0fafa68d638b729a506ba668165e29eea71a49 (diff)
downloadmevn-ecommerce-54677c68f50b7c105a1f6cc5e9593877781fc8d6.tar.gz
mevn-ecommerce-54677c68f50b7c105a1f6cc5e9593877781fc8d6.zip
Implemented JWT authentication using Passport.js
Diffstat (limited to 'server/routes')
-rw-r--r--server/routes/api.js5
1 files changed, 5 insertions, 0 deletions
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;