Troubleshoot email confirmation issues

Investigate and address problems related to users not receiving email confirmation messages.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 16:30:05 +00:00
parent 110f01f4ff
commit 2eb9dbfe64
3 changed files with 98 additions and 6 deletions

View File

@@ -1,4 +1,3 @@
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import { Button } from "@/components/ui/button";
@@ -8,6 +7,7 @@ import { verifyServerConnection } from "@/contexts/auth/auth.utils";
import { ServerStatus, SignUpResponse } from "./types";
import EmailConfirmation from "./EmailConfirmation";
import RegisterFormFields from "./RegisterFormFields";
import { supabase } from "@/lib/supabase";
interface RegisterFormProps {
signUp: (email: string, password: string, username: string) => Promise<SignUpResponse>;
@@ -107,6 +107,47 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
return true;
};
// 인증 이메일 재전송 기능
const handleResendVerificationEmail = async () => {
try {
// 현재 브라우저 URL 가져오기
const currentUrl = window.location.origin;
const redirectUrl = `${currentUrl}/login?auth_callback=true`;
const { error } = await supabase.auth.resend({
type: 'signup',
email,
options: {
emailRedirectTo: redirectUrl,
},
});
if (error) {
console.error('인증 메일 재전송 실패:', error);
toast({
title: "인증 메일 재전송 실패",
description: error.message || "인증 메일을 재전송하는 중 오류가 발생했습니다.",
variant: "destructive"
});
return;
}
toast({
title: "인증 메일 재전송 완료",
description: `${email}로 인증 메일이 재전송되었습니다. 이메일과 스팸 폴더를 확인해주세요.`,
});
console.log('인증 메일 재전송 성공:', email);
} catch (error: any) {
console.error('인증 메일 재전송 중 예외 발생:', error);
toast({
title: "인증 메일 재전송 오류",
description: error.message || "인증 메일을 재전송하는 중 오류가 발생했습니다.",
variant: "destructive"
});
}
};
const handleRegister = async (e: React.FormEvent) => {
e.preventDefault();
setRegisterError(null);
@@ -203,7 +244,8 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
if (emailConfirmationSent) {
return <EmailConfirmation
email={email}
onBackToForm={() => setEmailConfirmationSent(false)}
onBackToForm={() => setEmailConfirmationSent(false)}
onResendEmail={handleResendVerificationEmail}
/>;
}