@@ -277,4 +277,19 @@ app.get('/API/resourcelist', function (req, res) {
|
||||
return res.send(resourceList);
|
||||
});
|
||||
|
||||
app.post("/API/user/setname", function (req, res) {
|
||||
let { email } = req.body;
|
||||
if (email) {
|
||||
if (DEBUG) return res.status(status.OK).send();
|
||||
connection.query(`UPDATE user SET email = ${mysql.escape(email)} WHERE email = ${mysql.escape(req.user.email)}`, function (err, rows) {
|
||||
if (err)
|
||||
return res.status(status.INTERNAL_SERVER_ERROR).send("the username seems invalid or already taken - if you think this is an error contact the sys admin");
|
||||
req.user.email = email;
|
||||
return res.status(status.OK).send("username changed");
|
||||
});
|
||||
} else {
|
||||
return res.status(status.BAD_REQUEST).send("invalid data supplied");
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3001);
|
||||
|
||||
Reference in New Issue
Block a user