1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-05-10 15:33:04 +00:00
Signed-off-by: roxwize <rae@roxwize.xyz>
This commit is contained in:
Rae 5e 2024-12-26 16:24:04 -05:00
parent afc634b0d2
commit d173e6ea73
Signed by: rae
GPG key ID: 5B1A0FAB9BAB81EE
22 changed files with 1433 additions and 472 deletions

View file

@ -13,7 +13,7 @@ export default function(app: Express, db: NodePgDatabase) {
res.redirect("/");
return;
}
render(db, "register", "Sign up", res, req);
render(db, "register", "sign up", res, req);
});
app.post("/register", async (req, res) => {
if (req.session["loggedIn"]) {
@ -49,22 +49,6 @@ export default function(app: Express, db: NodePgDatabase) {
res.redirect("/register");
return;
}
// invite code checking
const code = (await db.select({ expires: inviteCodes.expires, confers: inviteCodes.confers }).from(inviteCodes).where(eq(inviteCodes.token, req.body.referral)).limit(1))[0];
if (!code) {
req.flash("error", "Invalid invite code! Make sure you pasted it in correctly WITH the hyphens.");
res.redirect("/register");
return;
}
const expiration = code.expires.getTime();
if (expiration > 0 && Date.now() >= expiration) {
req.flash("error", "That code is expired.");
res.redirect("/register");
return;
}
// we're verified now so get that dumb fucker out of the database
await db.delete(inviteCodes).where(eq(inviteCodes.token, req.body.referral));
// field conflicts
if (
@ -84,6 +68,22 @@ export default function(app: Express, db: NodePgDatabase) {
res.redirect("/register");
return;
}
// invite code checking
const code = (await db.select({ expires: inviteCodes.expires, confers: inviteCodes.confers }).from(inviteCodes).where(eq(inviteCodes.token, req.body.referral)).limit(1))[0];
if (!code) {
req.flash("error", "Invalid invite code! Make sure you pasted it in correctly WITH the hyphens.");
res.redirect("/register");
return;
}
const expiration = code.expires.getTime();
if (expiration > 0 && Date.now() >= expiration) {
req.flash("error", "That code is expired.");
res.redirect("/register");
return;
}
// we're verified now so get that dumb fucker out of the database
await db.delete(inviteCodes).where(eq(inviteCodes.token, req.body.referral));
const hash = await bcrypt.hash(req.body.pass, 10);
const { uid } = (
@ -117,7 +117,7 @@ export default function(app: Express, db: NodePgDatabase) {
res.redirect("/");
return;
}
render(db, "login", "Log in", res, req);
render(db, "login", "log in", res, req);
});
app.post("/login", async (req, res) => {
if (req.session["loggedIn"]) {