aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auth.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/auth.ts b/src/auth.ts
index c587fcf..fb37787 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -52,6 +52,11 @@ function checkErr(req, res, next) {
next();
}
+//Checks if user is still authenticated otherwise redirects
+function ensureAuthenticated(req, res, next) {
+ if (req.isAuthenticated()) { return next(); }
+ res.redirect('/login');
+}
//Configure local strategy to use with passport-js.
@@ -89,4 +94,6 @@ app.post('/login', checkErr, passport.authenticate('local', function(err, user)
}
}), genToken);
-app.get('/logout', ) \ No newline at end of file
+app.get('/logout', function(req, res) {
+ req.logout();
+}); \ No newline at end of file