From 1c1d87176e66bd24088f63122b2be5181fb9e96d Mon Sep 17 00:00:00 2001 From: Fahri Can Date: Thu, 16 Apr 2026 17:22:48 +0300 Subject: [PATCH] reg --- src/app/[locale]/(auth)/signup/page.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/app/[locale]/(auth)/signup/page.tsx b/src/app/[locale]/(auth)/signup/page.tsx index 1c031c5..ac7d747 100644 --- a/src/app/[locale]/(auth)/signup/page.tsx +++ b/src/app/[locale]/(auth)/signup/page.tsx @@ -24,6 +24,8 @@ import { PasswordInput } from "@/components/ui/forms/password-input"; import { Skeleton } from "@/components/ui/feedback/skeleton"; import { authService } from "@/lib/api/example/auth/service"; import { useState } from "react"; +import { signIn } from "next-auth/react"; +import { toaster } from "@/components/ui/feedback/toaster"; const schema = yup.object({ name: yup.string().required(), @@ -53,9 +55,26 @@ function SignUpPage() { firstName: formData.name, lastName: "", }); - router.replace("/signin"); - } catch { - // Error handled by api-service interceptor (toast + 422 display) + + const res = await signIn("credentials", { + redirect: false, + email: formData.email, + password: formData.password, + }); + + if (res?.error) { + throw new Error(res.error); + } + + router.replace("/home"); + } catch (error) { + if (error instanceof Error && error.message) { + toaster.error({ + title: error.message, + type: "error", + }); + } + // other errors are handled by api-service interceptor (toast + 422 display) } finally { setIsSubmitting(false); }