fix: auto-close signup modal when autoconfirm is enabled
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,9 @@ export function AuthModal({ onClose, renewalMode = false }: AuthModalProps) {
|
||||
const result = await auth.signUp(email, password)
|
||||
if (result.error) {
|
||||
setError(result.error)
|
||||
} else if (result.autoConfirmed) {
|
||||
// Auto-confirmed — user is already signed in
|
||||
onClose()
|
||||
} else {
|
||||
setSignupSuccess(true)
|
||||
}
|
||||
|
||||
@@ -62,11 +62,19 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
}, [])
|
||||
|
||||
const signUp = useCallback(async (email: string, password: string) => {
|
||||
if (!supabase) return { error: 'Supabase not configured' }
|
||||
if (!supabase) return { error: 'Supabase not configured', autoConfirmed: false }
|
||||
|
||||
const { error } = await supabase.auth.signUp({ email, password })
|
||||
if (error) return { error: error.message }
|
||||
return { error: null }
|
||||
const { data, error } = await supabase.auth.signUp({ email, password })
|
||||
if (error) return { error: error.message, autoConfirmed: false }
|
||||
|
||||
// If session exists, user was auto-confirmed (GOTRUE_MAILER_AUTOCONFIRM=true)
|
||||
const autoConfirmed = !!data.session
|
||||
if (autoConfirmed && data.user) {
|
||||
await recordPasswordAuth(data.user.id)
|
||||
setNeedsPasswordRenewal(false)
|
||||
}
|
||||
|
||||
return { error: null, autoConfirmed }
|
||||
}, [])
|
||||
|
||||
const signIn = useCallback(async (email: string, password: string) => {
|
||||
|
||||
Reference in New Issue
Block a user