Skip to content

Commit

Permalink
Chore: #291 로그인 에러 원인 파악을 위한 콘솔문 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoonyesol committed Dec 8, 2024
1 parent ba2ada6 commit cbe4bc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/user/auth-form/SocialButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function SocialButton({ provider, isSubmitting }: SocialButtonPro
const googleUrl = import.meta.env.VITE_GOOGLE_URL;
const kakaoUrl = import.meta.env.VITE_KAKAO_URL;

const isGoogle = provider === 'GOOGLE';
const isGoogle = provider === 'google';

const [isLoading, setIsLoading] = useState(false);
const { toastError } = useToast();
Expand Down
12 changes: 10 additions & 2 deletions src/pages/user/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default function SignInPage() {
try {
const response = await getUserInfo();
setUserInfo(response.data);
console.log(response.data);
} catch (error) {
console.error('유저정보 오류', error);
throw new Error('유저 정보를 가져오는 데 실패했습니다.');
}
};
Expand All @@ -43,27 +45,33 @@ export default function SignInPage() {
try {
const response = await login(formData);
if (!response.headers) throw new Error();
console.log('response', response);

const accessToken = response.headers.authorization;
if (!accessToken) throw new Error();
console.log('accessToken', accessToken);

onLogin(accessToken.split(' ')[1]);
} catch (error) {
const axiosError = error as AxiosError;
if (axiosError.response?.status === 401) {
throw new Error('아이디와 비밀번호를 한번 더 확인해 주세요.');
}
console.error('로그인 도중 오류', axiosError);
throw new Error('로그인 도중 오류가 발생했습니다.');
}
};

const onSubmit = async (formData: UserSignInForm) => {
try {
await handleLogin(formData);
console.log('로그인 완료');
await fetchUserInfo();
console.log('유저정보 가져옴');
navigate('/', { replace: true });
} catch (error) {
const axiosError = error as Error;
console.error('로그인 + 유저정보 오류', axiosError);
toastError(axiosError.message);
}
};
Expand Down Expand Up @@ -94,8 +102,8 @@ export default function SignInPage() {
<FooterLinks type="signIn" />
</AuthFormLayout>
<section className="bottom-0 flex flex-col gap-8 text-center">
<SocialButton isSubmitting={isSubmitting} provider="KAKAO" />
<SocialButton isSubmitting={isSubmitting} provider="GOOGLE" />
<SocialButton isSubmitting={isSubmitting} provider="kakao" />
<SocialButton isSubmitting={isSubmitting} provider="google" />
</section>
</>
);
Expand Down

0 comments on commit cbe4bc4

Please sign in to comment.