Files
zellyy-finance/src/contexts/auth/signUp.ts
gpt-engineer-app[bot] 068482e8e6 Refactor authActions module
Refactor authActions.ts into smaller files for better maintainability and readability.
2025-03-15 13:08:22 +00:00

38 lines
1.0 KiB
TypeScript

import { supabase } from '@/lib/supabase';
import { handleNetworkError, showAuthToast } from './auth.utils';
export const signUp = async (email: string, password: string, username: string) => {
try {
console.log('회원가입 시도:', { email, username });
const { data, error } = await supabase.auth.signUp({
email,
password,
options: {
data: {
username,
},
},
});
if (error) {
console.error('회원가입 오류:', error);
showAuthToast('회원가입 실패', error.message, 'destructive');
return { error, user: null };
}
showAuthToast('회원가입 성공', '이메일 확인 후 로그인해주세요.');
return { error: null, user: data.user };
} catch (error: any) {
console.error('회원가입 중 예외 발생:', error);
// 네트워크 오류 확인
const errorMessage = handleNetworkError(error);
showAuthToast('회원가입 오류', errorMessage, 'destructive');
return { error, user: null };
}
};