Fix TS2339 error in useLogin

The property 'user' might not exist on the returned object from signIn.
Handle the case where user is undefined.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 13:07:14 +00:00
parent a8537d5398
commit 8931ee4bb6
3 changed files with 15 additions and 5 deletions

View File

@@ -41,7 +41,8 @@ export const signIn = async (email: string, password: string) => {
return {
error: {
message: '서버 응답을 처리할 수 없습니다. CORS 프록시 설정을 확인하세요.'
}
},
user: null
};
}
@@ -72,7 +73,7 @@ export const signIn = async (email: string, password: string) => {
responseData?.error ||
'로그인에 실패했습니다. 이메일과 비밀번호를 확인하세요.';
return { error: { message: errorMessage } };
return { error: { message: errorMessage }, user: null };
}
} catch (error: any) {
console.error('로그인 중 예외 발생:', error);
@@ -82,7 +83,7 @@ export const signIn = async (email: string, password: string) => {
? '서버 연결에 실패했습니다. 네트워크 연결을 확인해주세요.'
: (error.message || '예상치 못한 오류가 발생했습니다.');
return { error: { message: errorMessage } };
return { error: { message: errorMessage }, user: null };
}
};

View File

@@ -5,7 +5,7 @@ export type AuthContextType = {
session: Session | null;
user: User | null;
loading: boolean;
signIn: (email: string, password: string) => Promise<{ error: any }>;
signIn: (email: string, password: string) => Promise<{ error: any; user?: any }>;
signUp: (email: string, password: string, username: string) => Promise<{ error: any, user: any }>;
signOut: () => Promise<void>;
resetPassword: (email: string) => Promise<{ error: any }>;