1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 13:14:06 +01:00

🎨 reformat

This commit is contained in:
Flam3rboy 2021-05-29 18:22:52 +02:00
parent 1383911771
commit a86efe97bb
3 changed files with 14 additions and 69 deletions

View File

@ -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;

View File

@ -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{
} else {
res.sendStatus(401);
}
});

View File

@ -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;
}