mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-26 13:07:22 +08:00
21 lines
433 B
TypeScript
21 lines
433 B
TypeScript
import { withoutRole } from "src/lib/auth";
|
|
import prisma from "src/lib/prismadb";
|
|
|
|
/**
|
|
* Updates the user's `name` field in the `User` table.
|
|
*/
|
|
const handler = withoutRole("banned", async (req, res, token) => {
|
|
const { username } = req.body;
|
|
const { name } = await prisma.user.update({
|
|
where: {
|
|
id: token.sub,
|
|
},
|
|
data: {
|
|
name: username,
|
|
},
|
|
});
|
|
res.json({ name });
|
|
});
|
|
|
|
export default handler;
|