require password for username change
This commit is contained in:
@@ -294,9 +294,15 @@ app.get('/API/resourcelist', function (req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post("/API/user/setname", function (req, res) {
|
app.post("/API/user/setname", function (req, res) {
|
||||||
let { email } = req.body;
|
let { email, password } = req.body;
|
||||||
if (email) {
|
if (email) {
|
||||||
if (DEBUG) return res.status(status.OK).send();
|
if (DEBUG) return res.status(status.OK).send();
|
||||||
|
try {
|
||||||
|
if (!await validatePassword(req.user.email, passport))
|
||||||
|
return res.status(status.UNAUTHORIZED).send("wrong password supplied");
|
||||||
|
} catch (e) {
|
||||||
|
return res.status(status.INTERNAL_SERVER_ERROR).send(e);
|
||||||
|
}
|
||||||
connection.query(`UPDATE user SET email = ${mysql.escape(email)} WHERE email = ${mysql.escape(req.user.email)}`, function (err, rows) {
|
connection.query(`UPDATE user SET email = ${mysql.escape(email)} WHERE email = ${mysql.escape(req.user.email)}`, function (err, rows) {
|
||||||
if (err)
|
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");
|
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");
|
||||||
|
|||||||
Reference in New Issue
Block a user