mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
Merge pull request #145 from bloomsirenix/master
Added Fully Functional Delete User Request and an Dummy Disable User one
This commit is contained in:
commit
0b783221f8
30
src/routes/users/@me/delete.ts
Normal file
30
src/routes/users/@me/delete.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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 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
|
||||||
|
|
||||||
|
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(401);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
10
src/routes/users/@me/disable.ts
Normal file
10
src/routes/users/@me/disable.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.post("/", (req, res) => {
|
||||||
|
// TODO:
|
||||||
|
res.sendStatus(204);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
Loading…
Reference in New Issue
Block a user