mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
🎨 reformat
This commit is contained in:
parent
1383911771
commit
a86efe97bb
@ -1,9 +1,6 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { UserModel, toObject } from "@fosscord/server-util";
|
|
||||||
import { getPublicUser } from "../../../util/User";
|
import { getPublicUser } from "../../../util/User";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
import { UserUpdateSchema } from "../../../schema/User";
|
|
||||||
import { check } from "../../../util/instanceOf";
|
|
||||||
|
|
||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
@ -15,5 +12,4 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
res.json(user);
|
res.json(user);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
@ -1,29 +1,18 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { UserModel,UserDocument, toObject } from "@fosscord/server-util";
|
import { UserModel } 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 bcrypt from "bcrypt";
|
import bcrypt from "bcrypt";
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.post("/", async (req: Request, res: Response) => {
|
router.post("/", async (req: Request, res: Response) => {
|
||||||
|
const user = await UserModel.findOne({ id: req.user_id }).exec(); //User object
|
||||||
|
|
||||||
const user = await UserModel.findOne(
|
let correctpass = await bcrypt.compare(req.body.password, user!.user_data.hash); //Not sure if user typed right password :/
|
||||||
{ 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) {
|
if (correctpass) {
|
||||||
await UserModel.deleteOne({id: req.user_id}).exec() //Yeetus user deletus
|
await UserModel.deleteOne({ id: req.user_id }).exec(); //Yeetus user deletus
|
||||||
|
|
||||||
res.sendStatus(204);
|
res.sendStatus(204);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
res.sendStatus(401);
|
res.sendStatus(401);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,53 +1,13 @@
|
|||||||
export const UserUpdateSchema = {
|
import { Length } from "../util/instanceOf";
|
||||||
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[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const UserModifySchema = {
|
export const UserModifySchema = {
|
||||||
username: String,
|
$username: new Length(String, 2, 32),
|
||||||
avatar: String || null,
|
$avatar: String,
|
||||||
|
$bio: new Length(String, 0, 190)
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface UserModifySchema {
|
export interface UserModifySchema {
|
||||||
username: string;
|
username?: string;
|
||||||
avatar: string | null;
|
avatar?: string | null;
|
||||||
|
bio?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user