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:
24
schemas/link/discord/link.js
Normal file
24
schemas/link/discord/link.js
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
14
schemas/link/discord/redirect.js
Normal file
14
schemas/link/discord/redirect.js
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user