refactor: automatically authenticate all requests setup through route helpers (#9357)

* refactor: automatically authenticate all requests setup through route helpers

* fix: removed connect-ensure-login dependency

* fix: bug with some middlewares not defined outside route helper methods
This commit is contained in:
Julian Lam
2021-03-08 14:03:22 -05:00
committed by GitHub
parent f388086ab9
commit 7da061f0d7
17 changed files with 52 additions and 38 deletions

View File

@@ -83,6 +83,7 @@ module.exports = function (middleware) {
}
middleware.authenticate = helpers.try(async (req, res, next) => {
winston.warn(`[middleware] middleware.authenticate has been deprecated, page and API routes are now automatically authenticated via setup(Page|API)Route. Use middleware.authenticateRequest (if not using route helper) and middleware.ensureLoggedIn instead. (request path: ${req.path})`);
if (!await authenticate(req, res)) {
return;
}
@@ -92,7 +93,7 @@ module.exports = function (middleware) {
next();
});
middleware.authenticateOrGuest = helpers.try(async (req, res, next) => {
middleware.authenticateRequest = helpers.try(async (req, res, next) => {
if (!await authenticate(req, res)) {
return;
}