oapi: oauth2
This commit is contained in:
parent
3a40254ca5
commit
1b1fbce4d3
Binary file not shown.
Binary file not shown.
@ -32,7 +32,21 @@ const router = Router();
|
|||||||
|
|
||||||
// TODO: scopes, other oauth types
|
// 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, scope, response_type, redirect_url } = req.query;
|
||||||
const { client_id } = req.query;
|
const { client_id } = req.query;
|
||||||
|
|
||||||
@ -56,7 +70,13 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
|||||||
id: req.user_id,
|
id: req.user_id,
|
||||||
bot: false,
|
bot: false,
|
||||||
},
|
},
|
||||||
select: ["id", "username", "avatar", "discriminator", "public_flags"],
|
select: [
|
||||||
|
"id",
|
||||||
|
"username",
|
||||||
|
"avatar",
|
||||||
|
"discriminator",
|
||||||
|
"public_flags",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const guilds = await Member.find({
|
const guilds = await Member.find({
|
||||||
@ -131,11 +151,33 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
|||||||
},
|
},
|
||||||
authorized: false,
|
authorized: false,
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
router.post(
|
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) => {
|
async (req: Request, res: Response) => {
|
||||||
const body = req.body as ApplicationAuthorizeSchema;
|
const body = req.body as ApplicationAuthorizeSchema;
|
||||||
// const { client_id, scope, response_type, redirect_url } = req.query;
|
// const { client_id, scope, response_type, redirect_url } = req.query;
|
||||||
|
|||||||
3
src/util/schemas/responses/OAuthAuthorizeResponse.ts
Normal file
3
src/util/schemas/responses/OAuthAuthorizeResponse.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface OAuthAuthorizeResponse {
|
||||||
|
location: string;
|
||||||
|
}
|
||||||
@ -31,6 +31,7 @@ export * from "./GuildWidgetJsonResponse";
|
|||||||
export * from "./GuildWidgetSettingsResponse";
|
export * from "./GuildWidgetSettingsResponse";
|
||||||
export * from "./LocationMetadataResponse";
|
export * from "./LocationMetadataResponse";
|
||||||
export * from "./MemberJoinGuildResponse";
|
export * from "./MemberJoinGuildResponse";
|
||||||
|
export * from "./OAuthAuthorizeResponse";
|
||||||
export * from "./Tenor";
|
export * from "./Tenor";
|
||||||
export * from "./TokenResponse";
|
export * from "./TokenResponse";
|
||||||
export * from "./UserProfileResponse";
|
export * from "./UserProfileResponse";
|
||||||
|
|||||||
Reference in New Issue
Block a user