From f8d5247d34136ec82d17aaf313b4c23a1c1ce934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20S=C3=A1nchez?= Date: Mon, 3 Jun 2024 17:23:00 -0600 Subject: [PATCH] tratando de arreglar el bug de login in con un parche en el login xd --- app/(auth)/login/page.tsx | 4 ++++ auth.config.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx index b516b23..051add2 100644 --- a/app/(auth)/login/page.tsx +++ b/app/(auth)/login/page.tsx @@ -2,9 +2,11 @@ import { loginAction } from "@/actions"; import FormTextInput from "@/components/FormTextInput"; import Link from "next/link"; +import { useRouter } from "next/navigation"; import toast from "react-hot-toast"; const Login = () => { + const router = useRouter(); const clientLoginAction = async (formData: FormData) => { const result = await loginAction(formData); if (result) { @@ -16,6 +18,8 @@ const Login = () => { toast.error("Something went wrong. Try again."); break; } + } else { + router.push("/dashboard"); } }; diff --git a/auth.config.ts b/auth.config.ts index fd7ce46..906c79a 100644 --- a/auth.config.ts +++ b/auth.config.ts @@ -64,7 +64,7 @@ export const authConfig = { return Response.redirect(new URL("/forbbiden", nextUrl)); } } - + console.log("url actual", nextUrl.pathname); if ( nextUrl.pathname.startsWith("/login") || nextUrl.pathname.startsWith("/register")