1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-05-10 23:33:07 +00:00

mipilin r9... Fimally

Signed-off-by: roxwize <rae@roxwize.xyz>
This commit is contained in:
Rae 5e 2025-01-28 17:05:54 -05:00
parent 961d963677
commit fa8fae4638
Signed by: rae
GPG key ID: 5B1A0FAB9BAB81EE
9 changed files with 217 additions and 150 deletions

View file

@ -68,6 +68,11 @@ export default function (app: Express, db: NodePgDatabase) {
return;
}
if (!(req.session["status"] & UserStatus.MODERATOR)) {
if (!(req.session["status"] & UserStatus.TRUSTED)) {
req.flash("error", "Only trusted users can perform this action.");
res.redirect(req.get("Referrer") || "/");
return;
}
const { codesUsed } = (
await db
.select({ codesUsed: count() })
@ -87,7 +92,7 @@ export default function (app: Express, db: NodePgDatabase) {
"error",
"You've generated the maximum of five codes this week. Your counter will reset next month."
);
res.redirect("/dashboard");
res.redirect(req.get("Referrer") || "/");
return;
}
@ -100,19 +105,19 @@ export default function (app: Express, db: NodePgDatabase) {
"success",
`Your code has been created as <b>${code}</b>. It expires in a week so use it ASAP!!!`
);
res.redirect("/dashboard");
res.redirect(req.get("Referrer") || "/");
return;
}
const expiration = new Date(req.body.expiration || 0);
if (req.body.expiration && expiration.getTime() <= Date.now()) {
req.flash("error", "Chosen expiration date is in the past.");
res.redirect("/mod");
res.redirect(req.get("Referrer") || "/");
return;
}
const code = await createInviteCode(db, req.session["uid"], expiration);
req.flash("success", `Your code has been created as <b>${code}</b>.`);
res.redirect("/mod");
res.redirect(req.get("Referrer") || "/");
});
}