Shitlist changes
This commit is contained in:
parent
5448067e98
commit
065a5c83fc
6 changed files with 40 additions and 21 deletions
|
@ -10,4 +10,4 @@ CLERK_SECRET_KEY=""
|
|||
CLERK_WEBHOOK_SIGNING_SECRET=""
|
||||
|
||||
#Misc
|
||||
APP_ENV=""
|
||||
SHIT_LIST=""
|
||||
|
|
|
@ -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">4️⃣0️⃣4️⃣</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{" "}
|
||||
|
|
|
@ -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!",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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...",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
22
app/services/helpers.server.ts
Normal file
22
app/services/helpers.server.ts
Normal 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;
|
||||
};
|
|
@ -1,8 +1,4 @@
|
|||
/** @type {import('@remix-run/dev').AppConfig} */
|
||||
export default {
|
||||
ignoredRouteFiles: ["**/.*"],
|
||||
// appDirectory: "app",
|
||||
// assetsBuildDirectory: "public/build",
|
||||
// publicPath: "/build/",
|
||||
// serverBuildPath: "build/index.js",
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue