Block banned users from adding requests or voting
Also, some minor refactoring.
This commit is contained in:
parent
ccfcc57540
commit
7de73c9565
3 changed files with 21 additions and 4 deletions
12
src/app.ts
12
src/app.ts
|
@ -71,6 +71,12 @@ app.post("/api/addRequest", async (request, response) => {
|
|||
response.send("Must be logged in");
|
||||
return;
|
||||
}
|
||||
var banned = await db.query(queries.checkBan).then((result: pg.QueryResult) => result.rowCount > 0);
|
||||
if (banned) {
|
||||
response.status(401);
|
||||
response.send("You are banned; you may not add new requests.");
|
||||
return;
|
||||
}
|
||||
if (!request.body.url) {
|
||||
response.status(400);
|
||||
response.send("Missing url");
|
||||
|
@ -186,6 +192,12 @@ app.post("/api/addVote", async (request,response) => {
|
|||
response.send("Must be logged in");
|
||||
return;
|
||||
}
|
||||
var banned = await db.query(queries.checkBan).then((result: pg.QueryResult) => result.rowCount > 0);
|
||||
if (banned) {
|
||||
response.status(401);
|
||||
response.send("You are banned; you may not vote on requests.");
|
||||
return;
|
||||
}
|
||||
if (!request.body.url) {
|
||||
response.status(400);
|
||||
response.send("Missing url");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue