diff --git a/src/lib/supabase.ts b/src/lib/supabase.ts index 8af48d5..70c6504 100644 --- a/src/lib/supabase.ts +++ b/src/lib/supabase.ts @@ -4,7 +4,7 @@ import { createClient } from '@supabase/supabase-js'; // Supabase URL과 anon key 설정 // 브라우저에서 CORS 문제가 자주 발생하므로 HTTPS URL로 변경 const supabaseUrl = import.meta.env.VITE_SUPABASE_URL || 'https://tzmywjqtluhwemhuflhi.supabase.co'; -const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY || 'yQKSViIU5I2/QTbTN93GnGxKC+Ny3KPE+gDhrMzlhG0='; +const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InR6bXl3anF0bHVod2VtaHVmbGhpIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDk1NDUzMTUsImV4cCI6MjAyNTEyMTMxNX0.iCPZvMm9KeRjxh2cE-rkpAIxf9XpZzGIpSZBXBSRfoU'; // 유효한 URL이 설정되었는지 확인 const isValidUrl = supabaseUrl && supabaseAnonKey && diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 4dadbee..2119254 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button"; import { ArrowRight, Mail, KeyRound, User, Eye, EyeOff } from "lucide-react"; import { useToast } from "@/hooks/useToast.wrapper"; import { useAuth } from "@/contexts/auth"; + const Register = () => { const [username, setUsername] = useState(""); const [email, setEmail] = useState(""); @@ -13,45 +14,43 @@ const Register = () => { const [confirmPassword, setConfirmPassword] = useState(""); const [showPassword, setShowPassword] = useState(false); const [isLoading, setIsLoading] = useState(false); - const { - toast - } = useToast(); + const { toast } = useToast(); const navigate = useNavigate(); - const { - signUp, - user - } = useAuth(); - + const { signUp, user } = useAuth(); + // 이미 로그인된 경우 메인 페이지로 리다이렉트 useEffect(() => { if (user) { navigate("/"); } }, [user, navigate]); + const handleRegister = async (e: React.FormEvent) => { e.preventDefault(); + if (!username || !email || !password || !confirmPassword) { toast({ title: "입력 오류", description: "모든 필드를 입력해주세요.", - variant: "destructive" + variant: "destructive", }); return; } + if (password !== confirmPassword) { toast({ title: "비밀번호 불일치", description: "비밀번호와 비밀번호 확인이 일치하지 않습니다.", - variant: "destructive" + variant: "destructive", }); return; } + setIsLoading(true); + try { - const { - error, - user - } = await signUp(email, password, username); + const { error, user } = await signUp(email, password, username); + if (!error && user) { // 데모 모드에서는 즉시 메인 페이지로 이동 navigate("/"); @@ -62,10 +61,12 @@ const Register = () => { setIsLoading(false); } }; - return
새 계정을 만들고 재정 관리를 시작하세요