Update error message
Update error message when signup is not allowed.
This commit is contained in:
@@ -15,6 +15,13 @@ export const signUp = async (email: string, password: string, username: string)
|
||||
|
||||
console.log('회원가입 시도:', email);
|
||||
|
||||
// Supabase anon 키 확인
|
||||
const supabaseKey = localStorage.getItem('supabase_key');
|
||||
if (!supabaseKey || supabaseKey.includes('your-onpremise-anon-key')) {
|
||||
showAuthToast('설정 오류', 'Supabase 설정이 올바르지 않습니다. 설정 페이지에서 확인해주세요.', 'destructive');
|
||||
return { error: { message: 'Supabase 설정이 올바르지 않습니다. 설정 페이지에서 확인해주세요.' }, user: null };
|
||||
}
|
||||
|
||||
// 기본 회원가입 시도
|
||||
try {
|
||||
const { data, error } = await supabase.auth.signUp({
|
||||
@@ -41,6 +48,14 @@ export const signUp = async (email: string, password: string, username: string)
|
||||
return await signUpWithDirectApi(email, password, username);
|
||||
}
|
||||
|
||||
// 401 오류 감지 및 처리
|
||||
if (error.message.includes('401') || error.message.includes('권한이 없습니다') ||
|
||||
error.message.includes('Unauthorized') || error.status === 401) {
|
||||
const errorMessage = '회원가입 권한이 없습니다. Supabase 설정 또는 권한을 확인하세요.';
|
||||
showAuthToast('회원가입 실패', errorMessage, 'destructive');
|
||||
return { error: { message: errorMessage }, user: null, redirectToSettings: true };
|
||||
}
|
||||
|
||||
// 기타 오류 처리
|
||||
let errorMessage = error.message;
|
||||
|
||||
@@ -87,6 +102,13 @@ export const signUp = async (email: string, password: string, username: string)
|
||||
} catch (error: any) {
|
||||
console.error('기본 회원가입 프로세스 예외:', error);
|
||||
|
||||
// 401 오류 감지 및 처리
|
||||
if (error.status === 401 || (error.message && error.message.includes('401'))) {
|
||||
const errorMessage = '회원가입 권한이 없습니다. Supabase 설정 또는 권한을 확인하세요.';
|
||||
showAuthToast('회원가입 실패', errorMessage, 'destructive');
|
||||
return { error: { message: errorMessage }, user: null, redirectToSettings: true };
|
||||
}
|
||||
|
||||
// 직접 API 호출로 대체 시도
|
||||
if (error.message && (
|
||||
error.message.includes('json') ||
|
||||
|
||||
@@ -15,6 +15,15 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
const proxyUrl = getSupabaseUrl(); // 프록시 적용된 URL
|
||||
const supabaseKey = localStorage.getItem('supabase_key') || supabase.supabaseKey;
|
||||
|
||||
// Supabase 키 유효성 검사
|
||||
if (!supabaseKey || supabaseKey.includes('your-onpremise-anon-key')) {
|
||||
return {
|
||||
error: { message: 'Supabase 설정이 올바르지 않습니다. 설정 페이지에서 확인해주세요.' },
|
||||
user: null,
|
||||
redirectToSettings: true
|
||||
};
|
||||
}
|
||||
|
||||
// 프록시 정보 로깅
|
||||
const usingProxy = isCorsProxyEnabled();
|
||||
const proxyType = getProxyType();
|
||||
@@ -49,12 +58,23 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
|
||||
console.log('회원가입 응답 상태:', response.status);
|
||||
|
||||
// 401 오류 처리 (권한 없음)
|
||||
if (response.status === 401) {
|
||||
showAuthToast('회원가입 실패', '회원가입 권한이 없습니다. Supabase 설정 또는 권한을 확인하세요.', 'destructive');
|
||||
return {
|
||||
error: { message: '회원가입 권한이 없습니다. Supabase 설정 또는 권한을 확인하세요.' },
|
||||
user: null,
|
||||
redirectToSettings: true
|
||||
};
|
||||
}
|
||||
|
||||
// HTTP 상태 코드 확인
|
||||
if (response.status === 404) {
|
||||
showAuthToast('회원가입 실패', '서버 경로를 찾을 수 없습니다. Supabase URL을 확인하세요.', 'destructive');
|
||||
return {
|
||||
error: { message: '서버 경로를 찾을 수 없습니다. Supabase URL을 확인하세요.' },
|
||||
user: null
|
||||
user: null,
|
||||
redirectToSettings: true
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,7 +95,8 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
error: {
|
||||
message: '회원가입 권한이 없습니다. Supabase 설정 또는 권한을 확인하세요.'
|
||||
},
|
||||
user: null
|
||||
user: null,
|
||||
redirectToSettings: true
|
||||
};
|
||||
}
|
||||
|
||||
@@ -147,7 +168,7 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
else if (response.status === 401) {
|
||||
const errorMessage = '회원가입 권한이 없습니다. Supabase 설정 또는 권한을 확인하세요.';
|
||||
showAuthToast('회원가입 실패', errorMessage, 'destructive');
|
||||
return { error: { message: errorMessage }, user: null };
|
||||
return { error: { message: errorMessage }, user: null, redirectToSettings: true };
|
||||
}
|
||||
// 다른 모든 오류 상태
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user