mirror of
https://git.sr.ht/~roxwize/mipilin
synced 2025-05-10 15:33:04 +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
|
@ -2,7 +2,7 @@ import { Express } from "express";
|
|||
import bcrypt from "bcrypt";
|
||||
import { render } from "./util.js";
|
||||
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
||||
import { inviteCodes, profiles, users } from "../db/schema.js";
|
||||
import { follows, inviteCodes, profiles, users } from "../db/schema.js";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
//! TEMP Also not sanitized like at all
|
||||
|
@ -21,6 +21,11 @@ export default function(app: Express, db: NodePgDatabase) {
|
|||
return;
|
||||
}
|
||||
// validation
|
||||
if (!req.body.name || !req.body.referral || !req.body.email || !req.body.pass) {
|
||||
req.flash("error", "A required field wasn't filled in.");
|
||||
res.redirect("/register");
|
||||
return;
|
||||
}
|
||||
if (req.body.referral.length < 22) {
|
||||
req.flash("error", "Invalid invite code! Make sure you pasted it in correctly WITH the hyphens.");
|
||||
res.redirect("/register");
|
||||
|
@ -36,7 +41,11 @@ export default function(app: Express, db: NodePgDatabase) {
|
|||
res.redirect("/register");
|
||||
return;
|
||||
}
|
||||
if (!req.body.name.match(/[A-Z0-9_-]/i)) {
|
||||
|
||||
//! dumb
|
||||
req.body.name = req.body.name.trim();
|
||||
const match = req.body.name.match(/[A-Z0-9_-]+/i);
|
||||
if (match?.[0] !== req.body.name) {
|
||||
req.flash(
|
||||
"error",
|
||||
"Username can only contain letters, numbers, underscores, hyphens, and periods!!"
|
||||
|
@ -101,6 +110,13 @@ export default function(app: Express, db: NodePgDatabase) {
|
|||
)[0];
|
||||
await db.insert(profiles).values({ user: uid });
|
||||
|
||||
// Follow me by default ;w;;;
|
||||
//! Also this assumes that im at id 1 which might not be true ever
|
||||
await db.insert(follows).values({
|
||||
userId: 1,
|
||||
followerId: uid
|
||||
});
|
||||
|
||||
req.session["loggedIn"] = true;
|
||||
req.session["status"] = code.confers;
|
||||
req.session["user"] = req.body.name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue