Altered API, read more
I moved /auth/account/privilege to /admin/privilege I also fixed PATCH and DELETE on /account
This commit is contained in:
+22
-3
@@ -1,3 +1,22 @@
|
||||
module.exports = {
|
||||
defaultAccount: require('./default-account')
|
||||
};
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
//middleware
|
||||
const tokenAuth = require('../utilities/token-auth');
|
||||
|
||||
router.use(tokenAuth);
|
||||
router.use((req, res, next) => {
|
||||
//check the user's privilege
|
||||
if (req.user.privilege != 'administrator') {
|
||||
return res.status(401).send('Admins only');
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
require('./default-account')(); //generate the default accouunt
|
||||
|
||||
//basic route management
|
||||
router.patch('/privilege', require('./account-privilege'));
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user