Shitlist changes

This commit is contained in:
Atridad Lahiji 2023-11-27 15:17:27 -07:00
parent 5448067e98
commit 065a5c83fc
No known key found for this signature in database
6 changed files with 40 additions and 21 deletions

View file

@ -9,5 +9,5 @@ CLERK_PUBLISHABLE_KEY=""
CLERK_SECRET_KEY=""
CLERK_WEBHOOK_SIGNING_SECRET=""
# Misc
APP_ENV=""
#Misc
SHIT_LIST=""

View file

@ -2,14 +2,21 @@ import { Link, isRouteErrorResponse, useRouteError } from "@remix-run/react";
export default function FourOhFour() {
const error = useRouteError();
// Default errors
let status = 500;
let message =
"Oops! This room does not appear to exist, or may have been deleted! 😢";
"Something wen't wrong! Please sign out, back in, and give it another try!";
// If error response is sent, use correct errors
if (isRouteErrorResponse(error)) {
message = error.statusText;
status = error.status;
}
return (
<span className="text-center">
<h1 className="text-5xl font-bold m-2">404</h1>
<h1 className="text-5xl font-bold m-2">Error {status}</h1>
<h1 className="text-5xl font-bold m-2">{message}</h1>
<h2 className="text-2xl font-bold m-2">
If you believe you reached this page in error, please file an issue{" "}

View file

@ -15,7 +15,7 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
if (!roomId) {
return json("RoomId Missing!", {
status: 400,
statusText: "BAD REQUEST!",
statusText: "The RoomId is Missing!",
});
}
@ -31,9 +31,9 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
});
if (!room) {
return json(undefined, {
throw new Response(null, {
status: 404,
statusText: "NOT FOUND!",
statusText: "NOT NOOOOOO!",
});
}

View file

@ -29,6 +29,7 @@ import { rooms } from "~/services/schema";
import { eq } from "drizzle-orm";
import { shitList } from "~/services/consts.server";
import FourOhFour from "~/components/FourOhFour";
import { isShit } from "~/services/helpers.server";
// Loader
export const loader: LoaderFunction = async (args) => {
@ -46,24 +47,17 @@ export const loader: LoaderFunction = async (args) => {
throw new Response(null, {
status: 404,
statusText:
"Oops! This room does not appear to exist, or may have been deleted! 😢",
"Oops! This room does not appear to exist, or may have been deleted!",
});
}
let isShit = false;
const email = sessionClaims.email as string;
shitList.forEach((shitItem) => {
if (email.includes(shitItem)) {
isShit = true;
}
});
if (isShit) {
if (isShit(email)) {
throw new Response(null, {
status: 404,
statusText:
"Wowee zowee! This wasn't supposed to happen! Maybe try refreshing the page... 🤔🧐",
"Wowee zowee! I'm sure I put that room around here somewhere...",
});
}

View file

@ -0,0 +1,22 @@
export const isShit = (email: string) => {
if (!process.env.SHIT_LIST) {
return false;
}
const shitListString = process.env.SHIT_LIST as string;
const shitList = shitListString.split(",");
let result = false;
shitList.forEach((shitItem) => {
if (email.includes(shitItem)) {
console.log(
`🔴 BLOCKED USEREMAIL: ${email}\n🔴 FAILED CONDITION: ${shitItem}`
);
result = true;
}
});
return result;
};

View file

@ -1,8 +1,4 @@
/** @type {import('@remix-run/dev').AppConfig} */
export default {
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// publicPath: "/build/",
// serverBuildPath: "build/index.js",
};