16 lines
429 B
TypeScript
16 lines
429 B
TypeScript
|
import isAdmin from "~/lib/server/middlewareButNotReally/isAdmin";
|
||
|
import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn";
|
||
|
import { User } from "~/models/user";
|
||
|
|
||
|
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,
|
||
|
},
|
||
|
});
|
||
|
});
|