From df84572148ece5b31476291481dfabc12a7e4809 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 24 Oct 2024 18:48:11 +0200 Subject: [PATCH] fix(api): :bug: Fix missing FormData acceptance for registration route --- api/api/v1/accounts/index.ts | 7 +++++-- config/config.example.toml | 11 +++++------ plugins/openid/index.ts | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/api/api/v1/accounts/index.ts b/api/api/v1/accounts/index.ts index 65f88ee6..59bd18af 100644 --- a/api/api/v1/accounts/index.ts +++ b/api/api/v1/accounts/index.ts @@ -1,4 +1,4 @@ -import { apiRoute, applyConfig, auth } from "@/api"; +import { apiRoute, applyConfig, auth, jsonOrForm } from "@/api"; import { tempmailDomains } from "@/tempmail"; import { createRoute } from "@hono/zod-openapi"; import { and, eq, isNull } from "drizzle-orm"; @@ -42,7 +42,10 @@ const route = createRoute({ path: "/api/v1/accounts", summary: "Create account", description: "Register a new account", - middleware: [auth(meta.auth, meta.permissions, meta.challenge)], + middleware: [ + auth(meta.auth, meta.permissions, meta.challenge), + jsonOrForm(), + ], request: { body: { content: { diff --git a/config/config.example.toml b/config/config.example.toml index fb4a47fd..682b773f 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -314,8 +314,7 @@ description = "A Versia Server instance" # URL to your instance banner # banner = "" -# Used for federation. -# Use the "generate-keys" CLI command to generate these keys +# Used for federation. If left empty or missing, the server will generate one for you. [instance.keys] public = "" private = "" @@ -414,10 +413,10 @@ forced = false # Overriden by the signups.registration setting allow_registration = true -[plugins.config."@versia/openid".keys] -# Use the "generate-keys" CLI command to generate these keys -public = "" -private = "" +# [plugins.config."@versia/openid".keys] +# Run Versia Server with those values missing to generate a new key +# public = "" +# private = "" # The provider MUST support OpenID Connect with .well-known discovery # Most notably, GitHub does not support this diff --git a/plugins/openid/index.ts b/plugins/openid/index.ts index 3972f244..fb9674ae 100644 --- a/plugins/openid/index.ts +++ b/plugins/openid/index.ts @@ -1,7 +1,7 @@ import { Hooks, Plugin } from "@versia/kit"; +import { User } from "@versia/kit/db"; import chalk from "chalk"; import { z } from "zod"; -import { User } from "@versia/kit/db"; import authorizeRoute from "./routes/authorize.ts"; import jwksRoute from "./routes/jwks.ts"; import ssoLoginCallbackRoute from "./routes/oauth/callback.ts";