fix: Remove ability to use GET for RPC API requests by default (#4042)

* fix: Remove ability to use GET for RPC API requests by default

* tsc
This commit is contained in:
Tom Moor
2022-09-02 10:05:40 +02:00
committed by GitHub
parent 2d29f0f042
commit c85f3bd7b4
10 changed files with 85 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ import auth from "@server/middlewares/authentication";
import { Team, NotificationSetting } from "@server/models";
import { authorize } from "@server/policies";
import { presentNotificationSetting } from "@server/presenters";
import { ContextWithState } from "@server/types";
import { assertPresent, assertUuid } from "@server/validation";
const router = new Router();
@@ -55,8 +56,8 @@ router.post("notificationSettings.delete", auth(), async (ctx) => {
};
});
router.post("notificationSettings.unsubscribe", async (ctx) => {
const { id, token } = ctx.body;
const handleUnsubscribe = async (ctx: ContextWithState) => {
const { id, token } = ctx.body as { id?: string; token?: string };
assertUuid(id, "id is required");
assertPresent(token, "token is required");
@@ -77,6 +78,9 @@ router.post("notificationSettings.unsubscribe", async (ctx) => {
}
ctx.redirect(`${env.URL}?notice=invalid-auth`);
});
};
router.get("notificationSettings.unsubscribe", handleUnsubscribe);
router.post("notificationSettings.unsubscribe", handleUnsubscribe);
export default router;