Refactor authActions module
Refactor authActions.ts into smaller files for better maintainability and readability.
This commit is contained in:
37
src/contexts/auth/signUp.ts
Normal file
37
src/contexts/auth/signUp.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
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 };
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user