make secure check

This commit is contained in:
cutestnekoaqua 2023-02-11 01:07:44 +01:00
parent f4861e9dc5
commit ecc0397dd3

View File

@ -151,11 +151,14 @@ mastoRouter.post("/oauth/token", async (ctx) => {
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
const generator = (megalodon as any).default;
const client = generator("misskey", BASE_URL, null) as MegalodonInterface;
const m = body.code.match(/^[a-zA-Z0-9-]+/);
if (!m.length) {
ctx.body = { error: "Invalid code" };
return;
}
let m = null;
if (body.code) {
m = body.code.match(/^[a-zA-Z0-9-]+/);
if (!m.length) {
ctx.body = { error: "Invalid code" };
return;
}
}
try {
const atData = await client.fetchAccessToken(
null,