mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 14:51:13 -05:00
Refactor: Implement sign-out and re-login flow
This commit is contained in:
@@ -33,8 +33,13 @@ export default function Auth() {
|
||||
const [signInCaptchaToken, setSignInCaptchaToken] = useState<string | null>(null);
|
||||
const [signInCaptchaKey, setSignInCaptchaKey] = useState(0);
|
||||
const [mfaFactorId, setMfaFactorId] = useState<string | null>(null);
|
||||
|
||||
const emailParam = searchParams.get('email');
|
||||
const messageParam = searchParams.get('message');
|
||||
const showPasswordSetupMessage = messageParam === 'complete-password-setup';
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
email: '',
|
||||
email: emailParam || '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
username: '',
|
||||
@@ -43,6 +48,13 @@ export default function Auth() {
|
||||
const defaultTab = searchParams.get('tab') || 'signin';
|
||||
const { user } = useAuth();
|
||||
|
||||
// Pre-fill email from query param
|
||||
useEffect(() => {
|
||||
if (emailParam) {
|
||||
setFormData(prev => ({ ...prev, email: emailParam }));
|
||||
}
|
||||
}, [emailParam]);
|
||||
|
||||
// Auto-redirect when user is authenticated
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
@@ -374,6 +386,15 @@ export default function Auth() {
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{showPasswordSetupMessage && (
|
||||
<Alert className="mb-4">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertDescription>
|
||||
Your password has been set. Please sign in with your email and password to complete the setup.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{mfaFactorId ? (
|
||||
<MFAChallenge
|
||||
factorId={mfaFactorId}
|
||||
|
||||
Reference in New Issue
Block a user