20 lines
460 B
TypeScript
20 lines
460 B
TypeScript
import isAdmin from "@server/middlewareButNotReally/isAdmin";
|
|
import isLoggedIn from "@server/middlewareButNotReally/isLoggedIn";
|
|
import { User } from "@models/user";
|
|
|
|
export default eventHandler(async (ev) => {
|
|
isLoggedIn(ev);
|
|
isAdmin(ev);
|
|
const body = await readBody(ev);
|
|
let idee = parseInt(getRouterParam(ev, "id")!);
|
|
await User.findByIdAndUpdate(idee, {
|
|
$set: {
|
|
banned: body.ban,
|
|
},
|
|
});
|
|
return {
|
|
success: true,
|
|
banned: body.ban,
|
|
};
|
|
});
|