Redirect to login with success message after signup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -1,10 +1,12 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate, Link } from 'react-router-dom';
|
||||
import { useNavigate, useLocation, Link } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
|
||||
export default function Login() {
|
||||
const { login } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const successMessage = location.state?.message || '';
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
@@ -73,6 +75,7 @@ export default function Login() {
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
{successMessage && <p style={{ color: '#22c55e', fontSize: 13, marginBottom: 12 }}>{successMessage}</p>}
|
||||
{error && <p style={{ color: '#ef4444', fontSize: 13, marginBottom: 12 }}>{error}</p>}
|
||||
<button type="submit" className="btn btn-primary w-full btn-lg" disabled={loading}>
|
||||
{loading ? 'Signing in...' : 'Sign In'}
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function Signup() {
|
||||
setError('');
|
||||
const { error: err } = await signup(form.email, form.password, form.name);
|
||||
if (err) { setError(err); setLoading(false); return; }
|
||||
navigate('/my-projects');
|
||||
navigate('/', { state: { message: 'Account created! Please sign in.' } });
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user