Skip to content

Commit 0c87268

Browse files
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 1ee1fb8 + c01319f commit 0c87268

File tree

20 files changed

+173
-175
lines changed

20 files changed

+173
-175
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"cloudinary": "^2.2.0",
2727
"clsx": "^2.1.1",
2828
"cmdk": "1.0.0",
29-
"cryptr": "^6.3.0",
3029
"debounce": "^2.1.1",
3130
"file-saver": "^2.0.5",
3231
"geist": "^1.3.0",
@@ -51,7 +50,6 @@
5150
"react-dom": "^18.3.0",
5251
"react-dropzone": "^14.2.3",
5352
"react-hot-toast": "^2.4.1",
54-
"react-icons": "^5.3.0",
5553
"tailwind-merge": "^2.5.3",
5654
"tailwindcss-animate": "^1.0.7",
5755
"use-debounce": "^10.0.3",

pnpm-lock.yaml

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/codechef_logo.svg

Lines changed: 14 additions & 0 deletions
Loading

public/papers.png

264 KB
Loading

src/app/api/auth/login/route.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { connectToDatabase } from "@/lib/mongoose";
22
import bcrypt from "bcrypt";
3-
import Cryptr from "cryptr";
43
import User, { type IUser } from "@/db/user";
54
import { generateToken } from "@/lib/auth";
65
import { NextResponse } from "next/server";
76
import { type LoginRequest } from "@/interface";
87

9-
const cryptr = new Cryptr(process.env.CRYPTO_SECRET || "default_crypto_secret");
10-
118
export async function POST(req: Request) {
12-
console.log(process.env.CRYPTO_SECRET);
139
await connectToDatabase();
1410

1511
const body = (await req.json()) as LoginRequest;
@@ -29,12 +25,10 @@ export async function POST(req: Request) {
2925

3026
console.log("User logged in:", token);
3127

32-
const encryptedResponse = cryptr.encrypt(JSON.stringify({
28+
return NextResponse.json({
3329
token,
3430
user: { id: user._id, email: user.email },
35-
}));
36-
37-
return NextResponse.json({res: encryptedResponse}, { status: 200 });
31+
}, { status: 200 });
3832
} catch (error) {
3933
console.error("Error logging in:", error);
4034
return NextResponse.json({ message: "Failed to login", error }, { status: 500 });

src/app/api/papers/route.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import { NextResponse, NextRequest } from "next/server";
22
import { connectToDatabase } from "@/lib/mongoose";
33
import Paper from "@/db/papers";
4-
import Cryptr from "cryptr";
54
import { type IPaper } from "@/interface";
65

7-
8-
const cryptr = new Cryptr(process.env.CRYPTO_SECRET ?? "default_crypto_secret");
9-
106
export const dynamic = "force-dynamic";
117

128
export async function GET(req: NextRequest) {
139
try {
1410
await connectToDatabase();
1511
const url = req.nextUrl.searchParams;
1612
const subject = url.get("subject");
17-
console.log("Subject:", subject);
1813
const escapeRegExp = (text: string) => {
1914
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2015
};
@@ -38,21 +33,20 @@ export async function GET(req: NextRequest) {
3833
{ status: 404 },
3934
);
4035
}
41-
36+
4237
const uniqueYears = Array.from(new Set(papers.map((paper) => paper.year)));
4338
const uniqueSlots = Array.from(new Set(papers.map((paper) => paper.slot)));
4439
const uniqueExams = Array.from(new Set(papers.map((paper) => paper.exam)));
4540

46-
const encryptedResponse = cryptr.encrypt(
47-
JSON.stringify({ papers, uniqueYears, uniqueSlots, uniqueExams }),
41+
return NextResponse.json(
42+
{ papers, uniqueYears, uniqueSlots, uniqueExams },
43+
{ status: 200 }
4844
);
49-
50-
return NextResponse.json({ res: encryptedResponse }, { status: 200 });
5145
} catch (error) {
5246
console.error("Error fetching papers by subject:", error);
5347
return NextResponse.json(
5448
{ message: "Failed to fetch papers", error },
55-
{ status: 500 },
49+
{ status: 500 }
5650
);
5751
}
5852
}

src/app/api/search/route.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { NextResponse } from "next/server";
22
import { connectToDatabase } from "@/lib/mongoose";
33
import Paper from "@/db/papers";
4-
import Cryptr from "cryptr";
5-
6-
const cryptr = new Cryptr(process.env.CRYPTO_SECRET ?? "default_crypto_secret");
74

85
export const dynamic = "force-dynamic";
96

@@ -16,7 +13,7 @@ export async function GET(req: Request) {
1613
if (!searchText) {
1714
return NextResponse.json(
1815
{ message: "Text query parameter is required" },
19-
{ status: 400 },
16+
{ status: 400 }
2017
);
2118
}
2219

@@ -29,18 +26,16 @@ export async function GET(req: Request) {
2926
if (subjects.length === 0) {
3027
return NextResponse.json(
3128
{ message: "No subjects found for the specified text" },
32-
{ status: 404 },
29+
{ status: 404 }
3330
);
3431
}
3532

36-
const encryptedResponse = cryptr.encrypt(JSON.stringify({ subjects }));
37-
38-
return NextResponse.json({ res: encryptedResponse }, { status: 200 });
33+
return NextResponse.json({ subjects }, { status: 200 });
3934
} catch (error) {
4035
console.error("Error fetching subjects:", error);
4136
return NextResponse.json(
4237
{ message: "Failed to fetch subjects", error },
43-
{ status: 500 },
38+
{ status: 500 }
4439
);
4540
}
4641
}

src/app/catalogue/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import CatalogueContent from "@/components/CatalogueContent";
44
import { Suspense } from "react";
55
import Navbar from "@/components/Navbar";
6-
import { RiLoader2Fill } from "react-icons/ri";
76
import Loader from "@/components/ui/loader";
87
const Catalogue = () => {
98
return (

src/app/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export const metadata: Metadata = {
99
metadataBase: new URL("https://papers.codechefvit.com/"),
1010
title: "Papers",
1111
description: "Made with ♡ by CodeChef-VIT",
12-
icons: [{ rel: "icon", url: "/chefshat.svg" }],
12+
icons: [{ rel: "icon", url: "/codechef_logo.svg" }],
1313
openGraph: {
1414
title: "Papers",
15-
images: [{ url: "/cookoff.png" }],
15+
images: [{ url: "/papers.png" }],
1616
url: "https://papers.codechefvit.com/",
1717
type: "website",
1818
description: "Made with ♡ by CodeChef-VIT",
@@ -39,7 +39,7 @@ export default function RootLayout({
3939
<body>
4040
<ThemeProvider
4141
attribute="class"
42-
defaultTheme="system"
42+
defaultTheme="dark"
4343
enableSystem
4444
disableTransitionOnChange
4545
>

src/app/papersadminlogin/page.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,43 @@ import { useRouter } from "next/navigation";
55
import {
66
type LoginResponse,
77
type ErrorResponse,
8-
type DecryptedLoginResponse,
98
} from "@/interface";
10-
import Cryptr from "cryptr";
119
import { handleAPIError } from "@/util/error";
12-
import { totalmem } from "os";
1310
import toast from "react-hot-toast";
1411
import { ApiError } from "next/dist/server/api-utils";
15-
const cryptr = new Cryptr(
16-
process.env.NEXT_PUBLIC_CRYPTO_SECRET ?? "default_crypto_secret",
17-
);
1812

1913
const LoginPage = () => {
2014
const router = useRouter();
2115
const [email, setEmail] = useState("");
2216
const [password, setPassword] = useState("");
2317
const [error, setError] = useState<string | null>(null);
18+
2419
async function apiLogin() {
2520
try {
2621
const response = await axios.post<LoginResponse>("/api/auth/login", {
2722
email,
2823
password,
2924
});
3025

31-
const { res } = response.data;
32-
const decryptedToken = cryptr.decrypt(res);
33-
try {
34-
const message = JSON.parse(decryptedToken) as DecryptedLoginResponse;
35-
const token = message.token;
36-
localStorage.setItem("token", token);
37-
return response.data;
38-
// router.push("/adminupload");
39-
} catch (error) {
40-
toast.error(`Failed to parse decrypted token${error}`);
41-
}
26+
const { token } = response.data;
27+
localStorage.setItem("token", token);
28+
return response.data;
4229
} catch (error) {
4330
throw handleAPIError(error);
4431
}
4532
}
33+
4634
const handleLogin = async () => {
4735
try {
4836
const response = await toast.promise(
4937
apiLogin(),
50-
5138
{
5239
loading: "Logging you in...",
5340
success: "Logged in!",
5441
error: (err: ApiError) => err.message,
5542
},
5643
);
57-
if (response && "res" in response) {
44+
if (response) {
5845
setTimeout(() => {
5946
router.push("/adminupload");
6047
}, 1500);

0 commit comments

Comments
 (0)