From 9f1064d656c33598338fbe332db13dfb573ed707 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Wed, 11 Jan 2023 16:54:39 +0900 Subject: [PATCH] Complete the handler todo and use withoutRole --- website/src/pages/api/valid_labels.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/website/src/pages/api/valid_labels.ts b/website/src/pages/api/valid_labels.ts index ab788c05..5f61ff2f 100644 --- a/website/src/pages/api/valid_labels.ts +++ b/website/src/pages/api/valid_labels.ts @@ -1,23 +1,12 @@ -import { getToken } from "next-auth/jwt"; +import { withoutRole } from "src/lib/auth"; import { oasstApiClient } from "src/lib/oasst_api_client"; /** - * TODO + * Returns the set of valid labels that can be applied to messages. */ -const handler = async (req, res) => { - const token = await getToken({ req }); - - // Return nothing if the user isn't registered. - if (!token) { - res.status(401).end(); - return; - } - - // Fetch the new task. +const handler = withoutRole("banned", async (req, res) => { const valid_labels = await oasstApiClient.fetch_valid_text(); - - // Send the results to the client. res.status(200).json(valid_labels); -}; +}); export default handler;