title: auto
des: auto note:auto
This commit is contained in:
@@ -4,8 +4,10 @@ import prisma from "@/app/lib/prisma";
|
||||
import { data } from "autoprefixer";
|
||||
import { NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { getConfig } from "@/bin/config";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
|
||||
if (req.method === "POST") {
|
||||
const body = await req.json();
|
||||
// MyConsole(body);
|
||||
@@ -35,7 +37,7 @@ export async function POST(req: Request) {
|
||||
username: data.username,
|
||||
}),
|
||||
{
|
||||
password: process.env.PWD as string,
|
||||
password: (await getConfig()).server.password,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -45,8 +47,7 @@ export async function POST(req: Request) {
|
||||
maxAge: 60 * 60 * 24 * 7,
|
||||
});
|
||||
|
||||
|
||||
return NextResponse.json({ status: 201});
|
||||
return NextResponse.json({ status: 201 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
|
||||
@@ -3,6 +3,7 @@ import prisma from "@/app/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
import { sealData, unsealData } from "iron-session";
|
||||
import {getConfig} from "@/bin/config";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method === "POST") {
|
||||
@@ -30,7 +31,7 @@ export async function POST(req: Request) {
|
||||
username: data.username,
|
||||
}),
|
||||
{
|
||||
password: process.env.PWD as string,
|
||||
password: (await getConfig()).server.password,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Validasi } from "@/app_modules/auth";
|
||||
|
||||
|
||||
export default function Page() {
|
||||
return <Validasi />;
|
||||
|
||||
return <Validasi />;
|
||||
}
|
||||
|
||||
11
src/bin/config/index.ts
Normal file
11
src/bin/config/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
"use server";
|
||||
import yaml from "yaml";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
const config: { server: { password: string } } = yaml.parse(
|
||||
fs.readFileSync(path.join(__dirname, "./../../../config.yaml")).toString()
|
||||
);
|
||||
|
||||
export async function getConfig() {
|
||||
return config;
|
||||
}
|
||||
Reference in New Issue
Block a user