This commit is contained in:
Timo Knuth
2025-10-18 17:55:32 +02:00
parent 254e6490b8
commit 91b78cb284
65 changed files with 4481 additions and 1078 deletions

View File

@@ -1,7 +1,6 @@
'use client';
import React, { useState } from 'react';
import { signIn } from 'next-auth/react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/Card';
@@ -43,19 +42,16 @@ export default function SignupPage() {
body: JSON.stringify({ name, email, password }),
});
if (response.ok) {
// Auto sign in after signup
const result = await signIn('credentials', {
email,
password,
redirect: false,
});
const data = await response.json();
if (result?.ok) {
router.push('/dashboard');
}
if (response.ok && data.success) {
// Store user in localStorage for client-side
localStorage.setItem('user', JSON.stringify(data.user));
// Redirect to dashboard
router.push('/dashboard');
router.refresh();
} else {
const data = await response.json();
setError(data.error || 'Failed to create account');
}
} catch (err) {
@@ -66,7 +62,8 @@ export default function SignupPage() {
};
const handleGoogleSignIn = () => {
signIn('google', { callbackUrl: '/dashboard' });
// Redirect to Google OAuth API route
window.location.href = '/api/auth/google';
};
return (