Improve authentication error handling
- Enhance error messages for authentication failures.
This commit is contained in:
@@ -9,7 +9,7 @@ import { useToast } from "@/hooks/useToast.wrapper";
|
||||
import { verifyServerConnection } from "@/contexts/auth/auth.utils";
|
||||
|
||||
interface RegisterFormProps {
|
||||
signUp: (email: string, password: string, username: string) => Promise<{
|
||||
signUp: (email: string, password: string) => Promise<{
|
||||
error: any;
|
||||
user: any;
|
||||
}>;
|
||||
@@ -88,7 +88,7 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const { error, user } = await signUp(email, password, username);
|
||||
const { error, user } = await signUp(email, password);
|
||||
|
||||
if (error) {
|
||||
setRegisterError(error.message || '알 수 없는 오류가 발생했습니다.');
|
||||
|
||||
@@ -11,7 +11,12 @@ export const signInWithDirectApi = async (email: string, password: string) => {
|
||||
try {
|
||||
// 로그인 API 엔드포인트 URL과 헤더 준비
|
||||
const supabaseUrl = supabase.auth.url;
|
||||
const tokenUrl = `${supabaseUrl}/auth/v1/token?grant_type=password`;
|
||||
// URL 경로 중복 방지를 위해 경로 확인 및 정규화
|
||||
const baseUrl = supabaseUrl?.endsWith('/auth/v1')
|
||||
? supabaseUrl
|
||||
: `${supabaseUrl}/auth/v1`;
|
||||
|
||||
const tokenUrl = `${baseUrl}/token?grant_type=password`;
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${supabase.supabaseKey}`,
|
||||
@@ -43,7 +48,7 @@ export const signInWithDirectApi = async (email: string, password: string) => {
|
||||
console.warn('API 경로를 찾을 수 없음 (404). 새 엔드포인트 시도 중...');
|
||||
|
||||
// 대체 엔드포인트 시도 (/token 대신 /signin)
|
||||
const signinUrl = `${supabaseUrl}/auth/v1/signin`;
|
||||
const signinUrl = `${baseUrl}/signin`;
|
||||
|
||||
try {
|
||||
const signinResponse = await fetch(signinUrl, {
|
||||
|
||||
@@ -12,8 +12,13 @@ export const signUpWithDirectApi = async (email: string, password: string) => {
|
||||
const supabaseUrl = supabase.auth.url;
|
||||
const supabaseKey = localStorage.getItem('supabase_key') || supabase.supabaseKey;
|
||||
|
||||
// URL 경로 중복 방지를 위해 경로 확인 및 정규화
|
||||
const baseUrl = supabaseUrl?.endsWith('/auth/v1')
|
||||
? supabaseUrl
|
||||
: `${supabaseUrl}/auth/v1`;
|
||||
|
||||
// 회원가입 API 엔드포인트 및 헤더 설정
|
||||
const signUpUrl = `${supabaseUrl}/auth/v1/signup`;
|
||||
const signUpUrl = `${baseUrl}/signup`;
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'apikey': supabaseKey,
|
||||
|
||||
Reference in New Issue
Block a user