Fix: Correct signUp type definition

The signUp function in AuthContextType was expecting only two arguments (email, password) but the RegisterForm component was passing three arguments (email, password, username). This commit updates the AuthContextType definition to match the actual usage in the RegisterForm component, resolving the TypeScript error.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 15:18:01 +00:00
parent 3c96a9deac
commit 0f07edaa98
3 changed files with 17 additions and 9 deletions

View File

@@ -1,4 +1,3 @@
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import { Label } from "@/components/ui/label";
@@ -9,7 +8,7 @@ import { useToast } from "@/hooks/useToast.wrapper";
import { verifyServerConnection } from "@/contexts/auth/auth.utils";
interface RegisterFormProps {
signUp: (email: string, password: string) => Promise<{
signUp: (email: string, password: string, username: string) => Promise<{
error: any;
user: any;
}>;
@@ -88,7 +87,7 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
setIsLoading(true);
try {
const { error, user } = await signUp(email, password);
const { error, user } = await signUp(email, password, username);
if (error) {
setRegisterError(error.message || '알 수 없는 오류가 발생했습니다.');

View File

@@ -3,7 +3,7 @@ import { supabase } from '@/lib/supabase';
import { showAuthToast, verifyServerConnection } from '@/utils/auth';
import { signUpWithDirectApi } from './signUpUtils';
export const signUp = async (email: string, password: string) => {
export const signUp = async (email: string, password: string, username: string) => {
try {
// 서버 연결 상태 확인
const connectionStatus = await verifyServerConnection();
@@ -20,6 +20,11 @@ export const signUp = async (email: string, password: string) => {
const { data, error } = await supabase.auth.signUp({
email,
password,
options: {
data: {
username, // 사용자 이름을 메타데이터에 저장
}
}
});
if (error) {
@@ -31,7 +36,7 @@ export const signUp = async (email: string, password: string) => {
error.message.includes('404') ||
error.message.includes('Not Found')) {
console.warn('기본 회원가입 실패, 직접 API 호출 시도:', error.message);
return await signUpWithDirectApi(email, password);
return await signUpWithDirectApi(email, password, username);
}
// 기타 오류 처리
@@ -83,7 +88,7 @@ export const signUp = async (email: string, password: string) => {
error.message.includes('404') ||
error.message.includes('Not Found'))) {
console.warn('직접 API 호출로 재시도:', error);
return await signUpWithDirectApi(email, password);
return await signUpWithDirectApi(email, password, username);
}
// 기타 예외 처리

View File

@@ -5,7 +5,7 @@ import { parseResponse, showAuthToast } from '@/utils/auth';
/**
* 직접 API 호출을 통한 회원가입
*/
export const signUpWithDirectApi = async (email: string, password: string) => {
export const signUpWithDirectApi = async (email: string, password: string, username: string) => {
try {
console.log('직접 API 호출로 회원가입 시도 중');
@@ -31,7 +31,11 @@ export const signUpWithDirectApi = async (email: string, password: string) => {
const response = await fetch(signUpUrl, {
method: 'POST',
headers,
body: JSON.stringify({ email, password })
body: JSON.stringify({
email,
password,
data: { username } // 사용자 메타데이터에 username 추가
})
});
console.log('회원가입 응답 상태:', response.status);
@@ -64,7 +68,7 @@ export const signUpWithDirectApi = async (email: string, password: string) => {
const user = {
id: responseData.id,
email: responseData.email,
user_metadata: responseData.user_metadata || {},
user_metadata: responseData.user_metadata || { username },
app_metadata: responseData.app_metadata || {},
created_at: responseData.created_at,
};