summaryrefslogtreecommitdiffstats
path: root/server/api/permissions.js
diff options
context:
space:
mode:
authorChristian Hofmaier2018-08-06 02:47:05 +0200
committerChristian Hofmaier2018-08-06 02:47:05 +0200
commit5a183cecd7101505e3cb0a60317ed810419b7e4e (patch)
treeaef41cba52160a18966930d5c16896edaa0e33ac /server/api/permissions.js
parent[webapp/searchtable] bugfix (diff)
downloadbas-5a183cecd7101505e3cb0a60317ed810419b7e4e.tar.gz
bas-5a183cecd7101505e3cb0a60317ed810419b7e4e.tar.xz
bas-5a183cecd7101505e3cb0a60317ed810419b7e4e.zip
language tags and function comments
Diffstat (limited to 'server/api/permissions.js')
-rw-r--r--server/api/permissions.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/api/permissions.js b/server/api/permissions.js
index ef7c5e8..5ed09e0 100644
--- a/server/api/permissions.js
+++ b/server/api/permissions.js
@@ -2,7 +2,14 @@
var path = require('path')
var db = require(path.join(__appdir, 'lib', 'sequelize'))
+// GET requests
module.exports.get = {
+
+ /*
+ * ?id=<ROLE_ID>
+ *
+ * @return: Returns the information about a role and it's permissions and groups.
+ */
getRoleById: function (req, res) {
db.role.findOne({ where: { id: req.query.id }, include: ['permissions', 'groups'] }).then(role => {
if (role) res.send(role)
@@ -10,6 +17,9 @@ module.exports.get = {
})
},
+ /*
+ * @return: Returns a list of all roles in the database.
+ */
getRoleList: function (req, res) {
db.role.findAll({
attributes: ['id', 'name', 'descr']
@@ -18,6 +28,9 @@ module.exports.get = {
})
},
+ /*
+ * @return: Returns a list of all permissions in the database.
+ */
getPermissionList: function (req, res) {
db.permission.findAll().then(function (permissions) {
res.status(200).send(permissions)
@@ -25,7 +38,14 @@ module.exports.get = {
}
}
+// POST requests
module.exports.post = {
+
+ /*
+ * id: <ROLE_ID>
+ *
+ * Deletes the role to the given id.
+ */
deleteRoles: function (req, res) {
const roleIds = req.body.id
@@ -34,6 +54,15 @@ module.exports.post = {
})
},
+ /*
+ * id: <ROLE_ID>
+ * name: <ROLE_NAME>
+ * descr: <ROLE_DESCRIPTION>
+ * permissions: <PERMISSION_IDS>
+ * groups: <GROUP_IDS>
+ *
+ * Creates or updates a role.
+ */
saveRole: function (req, res) {
const role = req.body