remove demo code
This commit is contained in:
@@ -12,9 +12,7 @@ import {
|
||||
LogIn,
|
||||
AlertCircle,
|
||||
Flag,
|
||||
Gamepad2,
|
||||
Shield,
|
||||
ChevronRight,
|
||||
} from 'lucide-react';
|
||||
|
||||
import Card from '@/components/ui/Card';
|
||||
@@ -97,31 +95,6 @@ export default function LoginPage() {
|
||||
},
|
||||
});
|
||||
|
||||
const handleDemoLogin = async () => {
|
||||
try {
|
||||
const { ServiceFactory } = await import('@/lib/services/ServiceFactory');
|
||||
const serviceFactory = new ServiceFactory(process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3001');
|
||||
const authService = serviceFactory.createAuthService();
|
||||
|
||||
// Get rememberMe value safely
|
||||
const rememberMe = formState.fields.rememberMe?.value ?? false;
|
||||
|
||||
await authService.demoLogin({
|
||||
role: 'driver',
|
||||
rememberMe,
|
||||
});
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
router.push(returnTo);
|
||||
} catch (error) {
|
||||
setFormError('Demo login failed. Please try again.');
|
||||
logErrorWithContext(error, {
|
||||
component: 'LoginPage',
|
||||
action: 'demo-login',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-deep-graphite flex">
|
||||
{/* Background Pattern */}
|
||||
@@ -164,8 +137,7 @@ export default function LoginPage() {
|
||||
<span>Secure login</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Gamepad2 className="w-4 h-4" />
|
||||
<span>iRacing verified</span>
|
||||
<span className="text-sm">iRacing verified</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -317,20 +289,6 @@ export default function LoginPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Demo Login */}
|
||||
<motion.button
|
||||
type="button"
|
||||
onClick={handleDemoLogin}
|
||||
disabled={formState.isSubmitting}
|
||||
whileHover={{ scale: 1.01 }}
|
||||
whileTap={{ scale: 0.99 }}
|
||||
className="w-full flex items-center justify-center gap-3 px-4 py-3 rounded-lg bg-gradient-to-r from-deep-graphite to-iron-gray border border-charcoal-outline text-gray-300 hover:border-primary-blue/30 transition-all disabled:opacity-50 group"
|
||||
>
|
||||
<Gamepad2 className="w-5 h-5 text-primary-blue" />
|
||||
<span>Demo Login</span>
|
||||
<ChevronRight className="w-4 h-4 text-gray-500 group-hover:translate-x-0.5 transition-transform" />
|
||||
</motion.button>
|
||||
|
||||
{/* Sign Up Link */}
|
||||
<p className="mt-6 text-center text-sm text-gray-400">
|
||||
Don't have an account?{' '}
|
||||
|
||||
@@ -15,13 +15,11 @@ import {
|
||||
User,
|
||||
Check,
|
||||
X,
|
||||
Gamepad2,
|
||||
Loader2,
|
||||
Car,
|
||||
Users,
|
||||
Trophy,
|
||||
Shield,
|
||||
ChevronRight,
|
||||
Sparkles,
|
||||
} from 'lucide-react';
|
||||
|
||||
@@ -239,26 +237,6 @@ export default function SignupPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDemoLogin = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const { ServiceFactory } = await import('@/lib/services/ServiceFactory');
|
||||
const serviceFactory = new ServiceFactory(process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3001');
|
||||
const authService = serviceFactory.createAuthService();
|
||||
|
||||
await authService.demoLogin({ role: 'driver' });
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
// Always redirect to dashboard after demo login
|
||||
router.push('/dashboard');
|
||||
} catch {
|
||||
setErrors({
|
||||
submit: 'Demo login failed. Please try again.',
|
||||
});
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Show loading while checking auth
|
||||
if (checkingAuth) {
|
||||
return (
|
||||
@@ -344,7 +322,6 @@ export default function SignupPage() {
|
||||
<span>Secure signup</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Gamepad2 className="w-4 h-4" />
|
||||
<span>iRacing integration</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -596,24 +573,10 @@ export default function SignupPage() {
|
||||
<div className="w-full border-t border-charcoal-outline" />
|
||||
</div>
|
||||
<div className="relative flex justify-center text-xs">
|
||||
<span className="px-4 bg-iron-gray text-gray-500">or sign up with</span>
|
||||
<span className="px-4 bg-iron-gray text-gray-500">or continue with</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Demo Login */}
|
||||
<motion.button
|
||||
type="button"
|
||||
onClick={handleDemoLogin}
|
||||
disabled={loading}
|
||||
whileHover={{ scale: 1.01 }}
|
||||
whileTap={{ scale: 0.99 }}
|
||||
className="w-full flex items-center justify-center gap-3 px-4 py-3 rounded-lg bg-gradient-to-r from-deep-graphite to-iron-gray border border-charcoal-outline text-gray-300 hover:border-primary-blue/30 transition-all disabled:opacity-50 group"
|
||||
>
|
||||
<Gamepad2 className="w-5 h-5 text-primary-blue" />
|
||||
<span>Demo Login</span>
|
||||
<ChevronRight className="w-4 h-4 text-gray-500 group-hover:translate-x-0.5 transition-transform" />
|
||||
</motion.button>
|
||||
|
||||
{/* Login Link */}
|
||||
<p className="mt-6 text-center text-sm text-gray-400">
|
||||
Already have an account?{' '}
|
||||
|
||||
@@ -140,29 +140,6 @@ export default function SponsorSignupPage() {
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const handleDemoLogin = async () => {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
// Use the demo login API instead of setting cookies
|
||||
const response = await fetch('/api/auth/demo-login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ role: 'sponsor' }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Demo login failed');
|
||||
}
|
||||
|
||||
router.push('/sponsor/dashboard');
|
||||
} catch (error) {
|
||||
console.error('Demo login failed:', error);
|
||||
alert('Demo login failed. Please check the API server status.');
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -206,22 +183,47 @@ export default function SponsorSignupPage() {
|
||||
setSubmitting(true);
|
||||
|
||||
try {
|
||||
// For demo purposes, use the demo login API with sponsor role
|
||||
// In production, this would create a real sponsor account
|
||||
const response = await fetch('/api/auth/demo-login', {
|
||||
// Create a sponsor account using the normal signup flow
|
||||
// The backend will handle creating the sponsor user with the appropriate role
|
||||
const response = await fetch('/api/auth/signup', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ role: 'sponsor' }),
|
||||
body: JSON.stringify({
|
||||
email: formData.contactEmail,
|
||||
password: formData.password,
|
||||
displayName: formData.companyName,
|
||||
// Additional sponsor-specific data
|
||||
sponsorData: {
|
||||
companyName: formData.companyName,
|
||||
websiteUrl: formData.websiteUrl,
|
||||
interests: formData.interests,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Signup failed');
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
throw new Error(errorData.message || 'Signup failed');
|
||||
}
|
||||
|
||||
// Auto-login after successful signup
|
||||
const loginResponse = await fetch('/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
email: formData.contactEmail,
|
||||
password: formData.password,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!loginResponse.ok) {
|
||||
throw new Error('Auto-login failed');
|
||||
}
|
||||
|
||||
router.push('/sponsor/dashboard');
|
||||
} catch (err) {
|
||||
console.error('Sponsor signup failed:', err);
|
||||
alert('Registration failed. Try again.');
|
||||
alert('Registration failed. ' + (err instanceof Error ? err.message : 'Try again.'));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
@@ -263,17 +265,6 @@ export default function SponsorSignupPage() {
|
||||
<ArrowRight className="w-5 h-5 ml-2" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Demo Login */}
|
||||
<div className="mt-6">
|
||||
<button
|
||||
onClick={handleDemoLogin}
|
||||
disabled={submitting}
|
||||
className="text-sm text-gray-500 hover:text-gray-400 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{submitting ? 'Loading...' : 'Try demo sponsor account →'}
|
||||
</button>
|
||||
</div>
|
||||
</SponsorHero>
|
||||
|
||||
{/* Platform Stats */}
|
||||
@@ -529,13 +520,6 @@ export default function SponsorSignupPage() {
|
||||
Create one
|
||||
</button>
|
||||
</p>
|
||||
<button
|
||||
onClick={handleDemoLogin}
|
||||
disabled={submitting}
|
||||
className="w-full text-sm text-gray-500 hover:text-gray-400 text-center"
|
||||
>
|
||||
Or try the demo account
|
||||
</button>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user