Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove bypass property
  • Loading branch information
regalijan committed Apr 15, 2024
1 parent 3d7cb08 commit fa2d97d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
1 change: 0 additions & 1 deletion app/routes/report.tsx
Expand Up @@ -130,7 +130,6 @@ export default function () {

const submitReq = await fetch("/api/reports/submit", {
body: JSON.stringify({
bypass: false,
description: description || undefined,
files: filelist,
turnstileResponse: logged_in ? undefined : turnstileToken,
Expand Down
23 changes: 3 additions & 20 deletions functions/api/reports/submit.ts
Expand Up @@ -2,15 +2,8 @@ import { jsonError, jsonResponse } from "../../common.js";
import upload from "../../upload.js";

export async function onRequestPost(context: RequestContext) {
const {
actions,
bypass,
description,
files,
senderTokenId,
turnstileResponse,
usernames,
} = context.data.body;
const { description, files, senderTokenId, turnstileResponse, usernames } =
context.data.body;

if (!context.data.current_user) {
if (typeof turnstileResponse !== "string")
Expand All @@ -36,15 +29,6 @@ export async function onRequestPost(context: RequestContext) {
if (!success) return jsonError("Captcha test failed", 403);
}

const origin = context.request.headers.get("Origin");
if (!origin) return jsonError("No origin header", 400);

if (bypass && !(context.data.current_user?.permissions & (1 << 5)))
return jsonError("Bypass directive cannot be used", 403);

if (typeof bypass !== "boolean")
return jsonError("Bypass must be a boolean", 400);

if (!Array.isArray(usernames))
return jsonError("Usernames must be type of array", 400);

Expand Down Expand Up @@ -218,7 +202,6 @@ export async function onRequestPost(context: RequestContext) {
created_at: Date.now(),
fcm_token: typeof senderTokenId === "string" ? senderTokenId : undefined,
id: reportId,
open: !bypass,
user: currentUser
? {
email: currentUser.email,
Expand All @@ -235,7 +218,7 @@ export async function onRequestPost(context: RequestContext) {
await context.env.D1.prepare(
"INSERT INTO reports (created_at, id, open, user) VALUES (?, ?, ?, ?);",
)
.bind(Date.now(), reportId, Number(!bypass), currentUser?.id || null)
.bind(Date.now(), reportId, 1, currentUser?.id || null)
.run();
} catch {}

Expand Down

0 comments on commit fa2d97d

Please sign in to comment.