refactor: streamline authentication and password handling

- Removed unnecessary parameters from the GET request in the auth config route.
- Adjusted import order in the forgot password hook for consistency.
- Cleaned up password validation logic in the login schema for better readability.
This commit is contained in:
Daniel Luiz Alves
2025-07-21 17:59:40 -03:00
parent 765810e4e5
commit 952cf27ecb
3 changed files with 4 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import { NextResponse } from "next/server";
const API_BASE_URL = process.env.API_BASE_URL || "http://localhost:3333";
export async function GET(req: NextRequest) {
export async function GET() {
try {
const url = `${API_BASE_URL}/auth/config`;

View File

@@ -9,7 +9,7 @@ import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
import { requestPasswordReset, getAuthConfig } from "@/http/endpoints";
import { getAuthConfig, requestPasswordReset } from "@/http/endpoints";
export type ForgotPasswordFormData = {
email: string;

View File

@@ -6,9 +6,7 @@ type TFunction = ReturnType<typeof useTranslations>;
export const createLoginSchema = (t: TFunction, passwordAuthEnabled: boolean = true) =>
z.object({
emailOrUsername: z.string().min(1, t("validation.emailOrUsernameRequired")),
password: passwordAuthEnabled
? z.string().min(1, t("validation.passwordRequired"))
: z.string().optional(),
password: passwordAuthEnabled ? z.string().min(1, t("validation.passwordRequired")) : z.string().optional(),
});
export type LoginFormValues = z.infer<ReturnType<typeof createLoginSchema>>;