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:
parent
961d963677
commit
fa8fae4638
9 changed files with 217 additions and 150 deletions
|
@ -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") || "/");
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue