Skip to content

Commit

Permalink
[#132] Fix: 로그인 전 내 정보 요청 에러 수정 (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-Jaemin420 authored Feb 9, 2024
1 parent a43a351 commit ced1436
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/apis/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ const refreshAccessToken = async (token: string) => {

return accessToken;
} catch (error) {
console.error(error);
removeLocalStorage("accessToken");
removeLocalStorage("refreshToken");

window.location.href = "/";
throw new Error("Failed to refresh token");
}
};
Expand Down
12 changes: 6 additions & 6 deletions src/assets/svg/big-activity.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
SignupResponse,
} from "@/types/auth";

import { $getLoggedInUserDetails } from "./user";

export const $checkEmail = atomWithMutation(() => ({
mutationFn: (email: string): Promise<CheckEmailNicknameResponse> => checkEmail(email),
}));
Expand All @@ -37,11 +35,8 @@ export const $signup = atomWithMutation(() => ({
mutationFn: (body: SignupRequest): Promise<SignupResponse> => postSignup(body),
}));

export const $login = atomWithMutation((get) => ({
export const $login = atomWithMutation(() => ({
mutationFn: (body: LoginRequest): Promise<LoginResponse> => postLogin(body),
onSuccess: async () => {
(await get($getLoggedInUserDetails)).refetch();
},
}));

export const $postKakaoToken = atomWithMutation(() => ({
Expand Down

0 comments on commit ced1436

Please sign in to comment.