mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-11 19:06:20 +00:00
Add basic login and register functionality
This commit is contained in:
@@ -3,20 +3,16 @@ const passport = require('passport');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
/* GET users listing. */
|
||||
router.get('/login', function(req, res, next) {
|
||||
res.render('login');
|
||||
router.post('/login/password', passport.authenticate('local'), function(req, res, next) {
|
||||
if(req.user) {
|
||||
res.json(req.user);
|
||||
} else {
|
||||
res.statusCode = 403;
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/login/password', passport.authenticate('local', {
|
||||
successRedirect: '/',
|
||||
failureRedirect: '/login',
|
||||
failureMessage: true
|
||||
}));
|
||||
|
||||
router.get('/logout', function(req, res, next) {
|
||||
req.logout();
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user