🎨 reformat
This commit is contained in:
		
							parent
							
								
									1383911771
								
							
						
					
					
						commit
						a86efe97bb
					
				| @ -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; | ||||
|  | ||||
| @ -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); | ||||
| 
 | ||||
| 	} | ||||
| }); | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy