summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-29 18:22:52 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-29 18:22:52 +0200
commita86efe97bb1e623a0f0cdf77f6d8343d5b182c49 (patch)
tree99d58b7732652466b51e2d2a4fc2e05ca716b950
parentautomatically embed links in message (diff)
downloadserver-a86efe97bb1e623a0f0cdf77f6d8343d5b182c49.tar.xz
:art: reformat
-rw-r--r--src/routes/users/#id/index.ts4
-rw-r--r--src/routes/users/@me/delete.ts25
-rw-r--r--src/schema/User.ts54
3 files changed, 14 insertions, 69 deletions
diff --git a/src/routes/users/#id/index.ts b/src/routes/users/#id/index.ts
index d5f3b788..185b2e5f 100644
--- a/src/routes/users/#id/index.ts
+++ b/src/routes/users/#id/index.ts
@@ -1,9 +1,6 @@
 import { Router, Request, Response } from "express";
-import { UserModel, toObject } from "@fosscord/server-util";
 import { getPublicUser } from "../../../util/User";
 import { HTTPError } from "lambert-server";
-import { UserUpdateSchema } from "../../../schema/User";
-import { check } from "../../../util/instanceOf";
 
 const router: Router = Router();
 
@@ -15,5 +12,4 @@ router.get("/", async (req: Request, res: Response) => {
 	res.json(user);
 });
 
-
 export default router;
diff --git a/src/routes/users/@me/delete.ts b/src/routes/users/@me/delete.ts
index ec4cc223..aef4006c 100644
--- a/src/routes/users/@me/delete.ts
+++ b/src/routes/users/@me/delete.ts
@@ -1,29 +1,18 @@
 import { Router, Request, Response } from "express";
-import { UserModel,UserDocument, toObject } from "@fosscord/server-util";
-import { getPublicUser } from "../../../util/User";
-import { HTTPError } from "lambert-server";
-import { UserUpdateSchema } from "../../../schema/User";
-import { check, FieldErrors, Length } from "../../../util/instanceOf";
-import { db } from "@fosscord/server-util";
+import { UserModel } from "@fosscord/server-util";
 import bcrypt from "bcrypt";
 const router = Router();
 
 router.post("/", async (req: Request, res: Response) => {
+	const user = await UserModel.findOne({ id: req.user_id }).exec(); //User object
 
-	const user = await UserModel.findOne(
-		{ id: req.user_id },
-		
-	).exec();  //User object
-	
-	let correctpass = await bcrypt.compare(req.body.password,user!.user_data.hash) //Not sure if user typed right password :/
-    if(correctpass){
-	await UserModel.deleteOne({id: req.user_id}).exec() //Yeetus user deletus
+	let correctpass = await bcrypt.compare(req.body.password, user!.user_data.hash); //Not sure if user typed right password :/
+	if (correctpass) {
+		await UserModel.deleteOne({ id: req.user_id }).exec(); //Yeetus user deletus
 
-	res.sendStatus(204);
-	}
-	else{
+		res.sendStatus(204);
+	} else {
 		res.sendStatus(401);
-
 	}
 });
 
diff --git a/src/schema/User.ts b/src/schema/User.ts
index 15f27088..d5a7b909 100644
--- a/src/schema/User.ts
+++ b/src/schema/User.ts
@@ -1,53 +1,13 @@
-export const UserUpdateSchema = {
-	id: String,
-    username: String,
-    discriminator: String,
-    avatar: String || null,
-    $phone: String,
-    desktop: Boolean,
-    mobile: Boolean,
-    premium: Boolean,
-    premium_type: Number,
-    bot: Boolean,
-    system: Boolean,
-    nsfw_allowed: Boolean,
-    mfa_enabled: Boolean,
-    created_at: Date,
-    verified: Boolean,
-    $email: String,
-    flags: BigInt,
-    public_flags: BigInt,
-    $guilds: [String],
-};
-
-export interface UserUpdateSchema {
-	id: string;
-    username: string;
-    discriminator: string;
-    avatar: string | null;
-    phone?: string;
-    desktop: boolean;
-    mobile: boolean;
-    premium: boolean;
-    premium_type: number;
-    bot: boolean;
-    system: boolean;
-    nsfw_allowed: boolean;
-    mfa_enabled: boolean;
-    created_at: Date;
-    verified: boolean;
-    email?: string;
-    flags: bigint;
-    public_flags: bigint;
-    guilds: string[];
-}
+import { Length } from "../util/instanceOf";
 
 export const UserModifySchema = {
-    username: String,
-    avatar: String || null,
+	$username: new Length(String, 2, 32),
+	$avatar: String,
+	$bio: new Length(String, 0, 190)
 };
 
 export interface UserModifySchema {
-    username: string;
-    avatar: string | null;
+	username?: string;
+	avatar?: string | null;
+	bio?: string;
 }