title: auto

des: auto
note:auto
This commit is contained in:
2023-10-03 11:00:16 +08:00
parent ab1bb590bf
commit fa46a3f055
7 changed files with 30 additions and 34 deletions

View File

@@ -6,8 +6,11 @@ import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import { getConfig } from "@/bin/config";
export async function POST(req: Request) {
import fs from "fs";
import yaml from "yaml";
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
export async function POST(req: Request) {
if (req.method === "POST") {
const body = await req.json();
// MyConsole(body);
@@ -37,7 +40,7 @@ export async function POST(req: Request) {
username: data.username,
}),
{
password: (await getConfig()).server.password,
password: await config.server.password,
}
);

View File

@@ -4,11 +4,15 @@ import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import { sealData, unsealData } from "iron-session";
import { getConfig } from "@/bin/config";
import yaml from "yaml";
import fs from "fs";
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
export async function POST(req: Request) {
if (req.method === "POST") {
const body = await req.json();
myConsole(body);
const data = await prisma.user.findUnique({
where: {
@@ -22,6 +26,8 @@ export async function POST(req: Request) {
},
});
myConsole(data)
if (!data) return NextResponse.json({ status: 404 });
if (data) {
@@ -31,15 +37,10 @@ export async function POST(req: Request) {
username: data.username,
}),
{
password: (await getConfig()).server.password,
password: (await config.server.password),
}
);
const un = await unsealData(res, {
password: (await getConfig()).server.password,
});
// console.log(JSON.stringify(un), "route validasi")
cookies().set({
name: "ssn",
value: res,