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)
|
const result = await auth.signUp(email, password)
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
setError(result.error)
|
setError(result.error)
|
||||||
|
} else if (result.autoConfirmed) {
|
||||||
|
// Auto-confirmed — user is already signed in
|
||||||
|
onClose()
|
||||||
} else {
|
} else {
|
||||||
setSignupSuccess(true)
|
setSignupSuccess(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,11 +62,19 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const signUp = useCallback(async (email: string, password: string) => {
|
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 })
|
const { data, error } = await supabase.auth.signUp({ email, password })
|
||||||
if (error) return { error: error.message }
|
if (error) return { error: error.message, autoConfirmed: false }
|
||||||
return { error: null }
|
|
||||||
|
// 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) => {
|
const signIn = useCallback(async (email: string, password: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user