oapi: oauth2

This commit is contained in:
Puyodead1 2023-03-24 21:43:18 -04:00
parent 3a40254ca5
commit 1b1fbce4d3
No known key found for this signature in database
GPG Key ID: A4FA4FEC0DD353FC
5 changed files with 142 additions and 96 deletions

Binary file not shown.

Binary file not shown.

View File

@ -32,7 +32,21 @@ const router = Router();
// TODO: scopes, other oauth types
router.get("/", route({}), async (req: Request, res: Response) => {
router.get(
"/",
route({
responses: {
// TODO: I really didn't feel like typing all of it out
200: {},
400: {
body: "APIErrorResponse",
},
404: {
body: "APIErrorResponse",
},
},
}),
async (req: Request, res: Response) => {
// const { client_id, scope, response_type, redirect_url } = req.query;
const { client_id } = req.query;
@ -56,7 +70,13 @@ router.get("/", route({}), async (req: Request, res: Response) => {
id: req.user_id,
bot: false,
},
select: ["id", "username", "avatar", "discriminator", "public_flags"],
select: [
"id",
"username",
"avatar",
"discriminator",
"public_flags",
],
});
const guilds = await Member.find({
@ -131,11 +151,33 @@ router.get("/", route({}), async (req: Request, res: Response) => {
},
authorized: false,
});
});
},
);
router.post(
"/",
route({ requestBody: "ApplicationAuthorizeSchema" }),
route({
requestBody: "ApplicationAuthorizeSchema",
query: {
client_id: {
type: "string",
},
},
responses: {
200: {
body: "OAuthAuthorizeResponse",
},
400: {
body: "APIErrorResponse",
},
403: {
body: "APIErrorResponse",
},
404: {
body: "APIErrorResponse",
},
},
}),
async (req: Request, res: Response) => {
const body = req.body as ApplicationAuthorizeSchema;
// const { client_id, scope, response_type, redirect_url } = req.query;

View File

@ -0,0 +1,3 @@
export interface OAuthAuthorizeResponse {
location: string;
}

View File

@ -31,6 +31,7 @@ export * from "./GuildWidgetJsonResponse";
export * from "./GuildWidgetSettingsResponse";
export * from "./LocationMetadataResponse";
export * from "./MemberJoinGuildResponse";
export * from "./OAuthAuthorizeResponse";
export * from "./Tenor";
export * from "./TokenResponse";
export * from "./UserProfileResponse";