fix folder
deskripsi: - ganti nama folder (user) ke (auth) - hapus folder auth
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { sessionCreate } from "@/app/auth/_lib/session_create";
|
||||
import { sessionCreate } from "@/app/(auth)/_lib/session_create";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { sessionCreate } from "@/app/auth/_lib/session_create";
|
||||
import { sessionCreate } from "@/app/(auth)/_lib/session_create";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { decrypt } from "@/app/auth/_lib/decrypt";
|
||||
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
||||
import { prisma } from "@/app/lib";
|
||||
import { cookies } from "next/headers";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { decrypt } from "@/app/auth/_lib/decrypt";
|
||||
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
||||
import _ from "lodash";
|
||||
import { cookies } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { decrypt } from "@/app/auth/_lib/decrypt";
|
||||
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
||||
import _ from "lodash";
|
||||
import { cookies } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { sessionCreate } from "../../_lib/session_create";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
nomor: "6281339158911",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
nomor: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) return NextResponse.json({ success: false }, { status: 404 });
|
||||
|
||||
const token = await sessionCreate({
|
||||
sessionKey: process.env.NEXT_PUBLIC_BASE_SESSION_KEY!,
|
||||
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
|
||||
user: user as any,
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true, token });
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET() {
|
||||
const del = cookies().delete(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
|
||||
|
||||
return NextResponse.json({ success: true, message: "Logout Berhasil" });
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
"use client";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function Page() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
|
||||
async function login() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch("/auth/api/login", {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
const dataText = await res.text();
|
||||
|
||||
if (!res.ok) {
|
||||
console.error(dataText);
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
|
||||
const dataJson = JSON.parse(dataText);
|
||||
console.log(dataJson);
|
||||
// window.location.replace("/dev/home");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Button loading={loading} onClick={login}>
|
||||
Login
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import { decrypt } from "../../../../app/auth/_lib/decrypt";
|
||||
import { decrypt } from "../../../../app/(auth)/_lib/decrypt";
|
||||
|
||||
export async function funGetUserIdByToken() {
|
||||
const SESSION_KEY = process.env.NEXT_PUBLIC_BASE_SESSION_KEY!;
|
||||
|
||||
@@ -24,33 +24,27 @@ export default function Register() {
|
||||
const [isValue, setIsValue] = useState(false);
|
||||
const focusTrapRef = useFocusTrap();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [idCode, setIdCode] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
const kodeId = localStorage.getItem("hipmi_auth_code_id");
|
||||
if (kodeId != null) {
|
||||
onCheckAuthCode({ kodeId: kodeId as string, onSetData: setNomor });
|
||||
onCheckAuthCode({ kodeId: kodeId as string });
|
||||
} else {
|
||||
console.log("code id not found");
|
||||
}
|
||||
}, [setNomor]);
|
||||
}, []);
|
||||
|
||||
async function onCheckAuthCode({
|
||||
kodeId,
|
||||
onSetData,
|
||||
}: {
|
||||
kodeId: string;
|
||||
onSetData: any;
|
||||
}) {
|
||||
async function onCheckAuthCode({ kodeId }: { kodeId: string }) {
|
||||
try {
|
||||
const respone = await apiGetCheckCodeOtp({ id: kodeId });
|
||||
if (respone) {
|
||||
onSetData(respone.nomor);
|
||||
setIdCode(kodeId);
|
||||
setNomor(respone.nomor);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error onCheckAuthCode:", error);
|
||||
}
|
||||
// const res = await fetch(`/api/auth/check?id=${kodeId}`);
|
||||
// const result = await res.json();
|
||||
}
|
||||
|
||||
async function onRegistarsi() {
|
||||
|
||||
@@ -181,18 +181,22 @@ export default function Validasi() {
|
||||
<>
|
||||
<UIGlobal_LayoutDefault>
|
||||
<Stack h={"100vh"}>
|
||||
<Box
|
||||
pt={"md"}
|
||||
px={"md"}
|
||||
style={{
|
||||
position: "sticky",
|
||||
top: 0,
|
||||
}}
|
||||
>
|
||||
<ActionIcon variant="transparent" onClick={() => onBack()}>
|
||||
<IconChevronLeft color="white" />
|
||||
</ActionIcon>
|
||||
</Box>
|
||||
{data && data.nomor !== "" ? (
|
||||
<Box
|
||||
pt={"md"}
|
||||
px={"md"}
|
||||
style={{
|
||||
position: "sticky",
|
||||
top: 0,
|
||||
}}
|
||||
>
|
||||
<ActionIcon variant="transparent" onClick={() => onBack()}>
|
||||
<IconChevronLeft color="white" />
|
||||
</ActionIcon>
|
||||
</Box>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
<Stack align="center" justify="center" h={"100vh"} spacing={50}>
|
||||
<Title order={2} color={MainColor.yellow}>
|
||||
|
||||
Reference in New Issue
Block a user