1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-07 19:32:34 +01:00

Added password check

✔️ Only works if user types right password
🚫 No more kids getting there account deleted by there brother
This commit is contained in:
Bloom Sirenix 2021-05-22 23:30:08 +02:00
parent d7d8868282
commit e874a946af

View File

@ -1,20 +1,29 @@
import { Router, Request, Response } from "express";
import { UserModel, toObject } from "@fosscord/server-util";
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 } from "../../../util/instanceOf";
import { db } from "@fosscord/server-util";
import bcrypt from "bcrypt";
const router = Router();
router.post("/", async (req: Request, res: Response) => {
// TODO:
//console.log(req.headers);
await UserModel.deleteOne({id: req.user_id}).exec()
const user = await UserModel.findOne(
{ id: req.user_id },
).exec(); //User object
//await usermodel.save();
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 the feetus user deletus
res.sendStatus(204);
}
else{
res.sendStatus(204);
}
});
export default router;