second commit

This commit is contained in:
2024-12-16 13:30:44 +05:30
parent b37f080da5
commit 803d521b73
41 changed files with 7242 additions and 255 deletions

View File

@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";
export async function GET(req: Request) {
const response = NextResponse.redirect(new URL("/login", req.url));
response.cookies.set("isAuth", "", {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
path: "/",
expires: new Date(0),
});
return response;
}

13
app/api/auth/route.tsx Normal file
View File

@@ -0,0 +1,13 @@
import { NextResponse } from "next/server";
export async function POST(req: Request) {
const { username, password } = await req.json();
if (username === "Wdipl" && password === "Admin@123") {
const response = NextResponse.json({ success: true });
response.cookies.set("isAuth", "true", { httpOnly: true });
return response;
}
return NextResponse.json({ success: false }, { status: 401 });
}

10
app/api/auth/schema.tsx Normal file
View File

@@ -0,0 +1,10 @@
import * as yup from "yup";
// Validation Schema with Yup
export const schema = yup.object({
username: yup.string().required("Username is required"),
password: yup
.string()
.min(6, "Password must be at least 6 characters")
.required("Password is required"),
});