mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
Allowed set username to be used by the admin to change any username.
This commit is contained in:
17
index.js
17
index.js
@@ -291,14 +291,27 @@ app.post('/api/setUsername', function (req, res) {
|
|||||||
let userID = req.query.userID;
|
let userID = req.query.userID;
|
||||||
let userName = req.query.username;
|
let userName = req.query.username;
|
||||||
|
|
||||||
|
let adminUserIDInput = req.query.adminUserID;
|
||||||
|
|
||||||
if (userID == undefined || userName == undefined || userID === "undefined") {
|
if (userID == undefined || userName == undefined || userID === "undefined") {
|
||||||
//invalid request
|
//invalid request
|
||||||
res.sendStatus(400);
|
res.sendStatus(400);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//hash the userID
|
if (adminUserIDInput != undefined) {
|
||||||
userID = getHash(userID);
|
//this is the admin controlling the other users account, don't hash the controling account's ID
|
||||||
|
adminUserIDInput = getHash(adminUserIDInput);
|
||||||
|
|
||||||
|
if (adminUserIDInput != adminUserID) {
|
||||||
|
//they aren't the admin
|
||||||
|
res.sendStatus(403);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//hash the userID
|
||||||
|
userID = getHash(userID);
|
||||||
|
}
|
||||||
|
|
||||||
//check if username is already set
|
//check if username is already set
|
||||||
db.prepare("SELECT count(*) as count FROM userNames WHERE userID = ?").get(userID, function(err, row) {
|
db.prepare("SELECT count(*) as count FROM userNames WHERE userID = ?").get(userID, function(err, row) {
|
||||||
|
|||||||
Reference in New Issue
Block a user