completed oauth implementation on hub and dispatch

This commit is contained in:
PxlLoewe
2025-02-03 00:45:55 +01:00
parent 93804855f1
commit 71b401f8ab
18 changed files with 327 additions and 16 deletions

View File

@@ -2,6 +2,7 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { signIn } from 'next-auth/react';
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { Toaster, toast } from 'react-hot-toast';
@@ -9,7 +10,7 @@ import { z } from 'zod';
export const Login = () => {
const [isLoading, setIsLoading] = useState(false);
const searchParams = useSearchParams();
const schema = z.object({
email: z.string().email(),
password: z.string(),
@@ -20,14 +21,14 @@ export const Login = () => {
const form = useForm<schemaType>({
resolver: zodResolver(schema),
});
console.log(form.formState.errors);
return (
<form
className="card-body"
onSubmit={form.handleSubmit(async () => {
setIsLoading(true);
const data = await signIn('credentials', {
callbackUrl: '/',
callbackUrl: searchParams.get('redirect') || '/',
email: form.getValues('email'),
password: form.getValues('password'),
});