mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-07 15:54:58 -05:00
fix: forgot one api endpoint
This commit is contained in:
parent
10e0c91d6a
commit
be3c0f749a
@ -32,47 +32,50 @@ import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { clerkClient, getAuth } from "@clerk/nextjs/server";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const { userId } = getAuth(req);
|
||||
const { userId } = getAuth(req);
|
||||
|
||||
if (!userId) {
|
||||
return res.status(401).json({ error: "Unauthorized" });
|
||||
}
|
||||
const { data } = req.body;
|
||||
if (!userId) {
|
||||
return res.status(401).json({ error: "Unauthorized" });
|
||||
}
|
||||
const { data } = req.body;
|
||||
|
||||
if (data === undefined) {
|
||||
res.status(400).send({ message: "Couldn't find data" });
|
||||
return;
|
||||
}
|
||||
const { type } = req.body;
|
||||
if (data === undefined) {
|
||||
res.status(400).send({ message: "Couldn't find data" });
|
||||
return;
|
||||
}
|
||||
const { type } = req.body;
|
||||
|
||||
if (type === undefined) {
|
||||
res.status(400).send({ message: "Couldn't find data" });
|
||||
return;
|
||||
}
|
||||
if (data === null) {
|
||||
clerkClient.users.updateUserMetadata(userId, {
|
||||
publicMetadata: { [type]: null },
|
||||
});
|
||||
res.status(200).send({ message: "Success" });
|
||||
}
|
||||
if (type !== "srv" && type !== "ipr" && type !== "pad")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
if (type === undefined) {
|
||||
res.status(400).send({ message: "Couldn't find data" });
|
||||
return;
|
||||
}
|
||||
if (data === null) {
|
||||
await (
|
||||
await clerkClient()
|
||||
).users.updateUserMetadata(userId, {
|
||||
publicMetadata: { [type]: null },
|
||||
});
|
||||
res.status(200).send({ message: "Success" });
|
||||
}
|
||||
if (type !== "srv" && type !== "ipr" && type !== "pad")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
|
||||
if (type === "srv" && typeof data !== "boolean")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
if (type === "srv" && typeof data !== "boolean")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
|
||||
if (type === "ipr" && typeof data !== "number")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
if (type === "ipr" && typeof data !== "number")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
|
||||
if (type === "pad" && typeof data !== "number")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
if (type === "pad" && typeof data !== "number")
|
||||
return res.status(400).send({ message: "Couldn't find data" });
|
||||
|
||||
clerkClient.users.updateUserMetadata(userId, {
|
||||
publicMetadata: { [type]: typeof data === "number" ? data.toString() : data },
|
||||
});
|
||||
res.status(200).send({ message: "Success" });
|
||||
(await clerkClient()).users.updateUserMetadata(userId, {
|
||||
publicMetadata: {
|
||||
[type]: typeof data === "number" ? data.toString() : data,
|
||||
},
|
||||
});
|
||||
res.status(200).send({ message: "Success" });
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user