Add Discord OAuth2 account linking and login support

Introduces Discord OAuth2 integration for account association and login, including new routes for linking, unlinking, and authenticating via Discord. Adds supporting services, repositories, and schema validation for the OAuth2 flow. Refactors database schema and queries for consistency, and updates dependencies to include required OAuth2 libraries.
This commit is contained in:
2026-01-11 21:03:12 +01:00
parent 5b81f57adb
commit c5b6f6c107
19 changed files with 656 additions and 36 deletions

View File

@@ -0,0 +1,24 @@
const z = require("zod")
module.exports = {
GET: {
query: z.object({
code: z.string({ required_error: "Authorisation code required" }),
state: z.string({ required_error: "The state parameter is required." })
}),
error: {
code: 400,
message: "Invalid Discord callback settings"
}
},
DELETE: {
headers: z.object({
authorization: z.string({ required_error: "The authentication token is required." })
.regex(/^Bearer\s.+/, { message: "Invalid Authorization header format (Bearer token expected)" })
}),
error: {
code: 401,
message: "Authentication required for disassociation"
}
}
}

View File

@@ -0,0 +1,14 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
authorization: z.string({ required_error: "The authentication token is required." })
.regex(/^Bearer\s.+/, { message: "Invalid Authorization header format (Bearer token expected)" })
}),
error: {
code: 401,
message: "Authentication required to generate the link URL"
}
}
}