2023-12-20 17:23:31 -05:00
|
|
|
import isAdmin from "@server/middlewareButNotReally/isAdmin";
|
|
|
|
import isLoggedIn from "@server/middlewareButNotReally/isLoggedIn";
|
|
|
|
import { User } from "@models/user";
|
2023-10-10 21:58:29 -04:00
|
|
|
|
|
|
|
export default eventHandler(async (ev) => {
|
|
|
|
isLoggedIn(ev);
|
|
|
|
isAdmin(ev);
|
|
|
|
const b = await readBody(ev);
|
|
|
|
let idee = parseInt(getRouterParam(ev, "id")!);
|
|
|
|
await User.findByIdAndUpdate(idee, {
|
|
|
|
$set: {
|
|
|
|
"profile.isAdmin": b.promote,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|