mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 03:29:37 +02:00
Backend: auth for config and queries. Refactor of middleware exports
This commit is contained in:
parent
e3f167921c
commit
22471d64c7
10 changed files with 43 additions and 31 deletions
8
middleware/index.js
Normal file
8
middleware/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
asyncWrapper: require('./asyncWrapper'),
|
||||
auth: require('./auth'),
|
||||
errorHandler: require('./errorHandler'),
|
||||
upload: require('./multer'),
|
||||
requireAuth: require('./requireAuth'),
|
||||
requireBody: require('./requireBody'),
|
||||
};
|
11
middleware/requireAuth.js
Normal file
11
middleware/requireAuth.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const ErrorResponse = require('../utils/ErrorResponse');
|
||||
|
||||
const requireAuth = (req, res, next) => {
|
||||
if (!req.isAuthenticated) {
|
||||
return next(new ErrorResponse('Unauthorized', 401));
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
module.exports = requireAuth;
|
Loading…
Add table
Add a link
Reference in a new issue