Refactor authActions module
Refactor authActions.ts into smaller files for better maintainability and readability.
This commit is contained in:
28
src/contexts/auth/resetPassword.ts
Normal file
28
src/contexts/auth/resetPassword.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
import { supabase } from '@/lib/supabase';
|
||||
import { handleNetworkError, showAuthToast } from './auth.utils';
|
||||
|
||||
export const resetPassword = async (email: string) => {
|
||||
try {
|
||||
const { error } = await supabase.auth.resetPasswordForEmail(email, {
|
||||
redirectTo: window.location.origin + '/reset-password',
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('비밀번호 재설정 오류:', error);
|
||||
showAuthToast('비밀번호 재설정 실패', error.message, 'destructive');
|
||||
return { error };
|
||||
}
|
||||
|
||||
showAuthToast('비밀번호 재설정 이메일 전송됨', '이메일을 확인하여 비밀번호를 재설정해주세요.');
|
||||
return { error: null };
|
||||
} catch (error: any) {
|
||||
console.error('비밀번호 재설정 중 예외 발생:', error);
|
||||
|
||||
// 네트워크 오류 확인
|
||||
const errorMessage = handleNetworkError(error);
|
||||
|
||||
showAuthToast('비밀번호 재설정 오류', errorMessage, 'destructive');
|
||||
return { error };
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user