mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-18 05:28:27 +03:00
more lenient privateIDUsername checks
- disallow username = privateID - disallow username = other privateID on username table if length > minLength
This commit is contained in:
@@ -33,14 +33,9 @@ export async function setUsername(req: Request, res: Response): Promise<Response
|
||||
userName = userName.replace(/[\u0000-\u001F\u007F-\u009F]/g, "");
|
||||
|
||||
// check privateID against publicID
|
||||
/*
|
||||
if (!await checkPrivateUsername(userName, userID)) {
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
*/
|
||||
if (userName == userID) {
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
|
||||
if (adminUserIDInput != undefined) {
|
||||
//this is the admin controlling the other users account, don't hash the controling account's ID
|
||||
@@ -100,11 +95,10 @@ export async function setUsername(req: Request, res: Response): Promise<Response
|
||||
}
|
||||
|
||||
async function checkPrivateUsername(username: string, userID: string): Promise<boolean> {
|
||||
const userIDHash = await getHashCache(userID);
|
||||
if (username == userID) return false;
|
||||
if (username.length <= config.minUserIDLength) return true; // don't check for cross matches <= 30 characters
|
||||
const userNameHash = await getHashCache(username);
|
||||
if (userIDHash == userNameHash) return false;
|
||||
const sponsorTimeRow = await db.prepare("get", `SELECT "userID" FROM "sponsorTimes" WHERE "userID" = ? LIMIT 1`, [userNameHash]);
|
||||
const userNameRow = await db.prepare("get", `SELECT "userID" FROM "userNames" WHERE "userID" = ? LIMIT 1`, [userNameHash]);
|
||||
if ((sponsorTimeRow || userNameRow)?.userID) return false;
|
||||
if (userNameRow?.userID) return false;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user