summaryrefslogtreecommitdiffstats
path: root/server/api/users.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/users.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/users.js')
-rw-r--r--server/api/users.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/server/api/users.js b/server/api/users.js
index 2af6cb6..deb69e1 100644
--- a/server/api/users.js
+++ b/server/api/users.js
@@ -4,7 +4,9 @@ var path = require('path')
var db = require(path.join(__appdir, 'lib', 'sequelize'))
var jwt = require('jsonwebtoken')
+// GET requests
module.exports.get = {
+
getUserInfo: function (req, res) {
// Because veryfyToken was succesfully excecuted the request has the attribute token.
const token = req.token
@@ -22,6 +24,9 @@ module.exports.get = {
})
},
+ /*
+ * @return: Returns a list of all users in the database and their given roles.
+ */
getUserList: function (req, res) {
db.user.findAll({
attributes: ['id', 'username', 'name'],
@@ -32,7 +37,15 @@ module.exports.get = {
}
}
+// POST requests
module.exports.post = {
+
+ /*
+ * roleIds: <ROLE_IDS>
+ * userIds: <USER_IDS>
+ *
+ * Adds the given roles to the given users in the database.
+ */
grantRoles: function (req, res) {
const roleIds = req.body.roleIds
const userIds = req.body.userIds
@@ -45,6 +58,12 @@ module.exports.post = {
})
},
+ /*
+ * roleIds: <ROLE_IDS>
+ * userIds: <USER_IDS>
+ *
+ * Removes the given roles from the given users in the database.
+ */
revokeRoles: function (req, res) {
const roleIds = req.body.roleIds
const userIds = req.body.userIds