Add authenticated login and SSO protection
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { getApiSettings, saveApiSettings } from "@/lib/server/app-settings";
|
||||
import { jsonError, jsonOk, readJsonBody } from "@/lib/server/api";
|
||||
import { requireAppUser } from "@/lib/server/auth/current-user";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
await requireAppUser();
|
||||
return jsonOk(await getApiSettings());
|
||||
} catch (error) {
|
||||
return jsonError(error, 500);
|
||||
@@ -13,6 +15,7 @@ export async function GET() {
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
await requireAppUser();
|
||||
const body = await readJsonBody<{ values?: Record<string, unknown> }>(request);
|
||||
return jsonOk(await saveApiSettings(body.values || {}));
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user