Skip to content

Commit

Permalink
feat: 자동 로그인 및 accessToken 로직 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
ooherin committed Oct 11, 2024
1 parent 5ac08cf commit f8de14f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 3 additions & 2 deletions frontend/src/apis/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { API_ERROR_MESSAGE } from '@/apis/error/ErrorMessage';
import HTTPError from '@/apis/error/HttpError';
import { postReissueAccessToken } from '@/apis/user';
import { HTTP_STATUS_CODE } from '@/constants/httpErrorMessage';

let reissueAccessToken = false;
let reissueAccessTokenFailed = false;
Expand Down Expand Up @@ -42,7 +43,7 @@ const request = async ({ url, method, body, headers = {} }: RequestProps) => {
}
throw error;
} else {
throw new HTTPError(400, '네트워크 에러가 발생했습니다.');
throw new HTTPError(HTTP_STATUS_CODE.NETWORK_ERROR, '');
}
}
};
Expand Down Expand Up @@ -75,7 +76,7 @@ const retryRequest = async ({ url, method, body, headers = {}, signal }: Request
if (error instanceof HTTPError) {
throw new HTTPError(error.statusCode, error.message);
} else {
throw new HTTPError(400, '네트워크 에러가 발생했습니다.');
throw new HTTPError(HTTP_STATUS_CODE.NETWORK_ERROR, '');
}
}
};
Expand Down
14 changes: 5 additions & 9 deletions frontend/src/hooks/useIsValidUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ const useIsValidUser = () => {
const navigate = useNavigate();

const fetchIsUserValid = async () => {
try {
const isValid = await getIsUserValid();
if (isValid) {
navigate(ROUTE_PATH.home);
//TODO: 00님 환영합니다. 또는 자동 로그인 되었습니다. 토스트 띄워주기
}
//TODO: access 재발급 요청
} catch (err) {
console.error(err);
const isValid = await getIsUserValid();
if (isValid) {
navigate(ROUTE_PATH.home);
//TODO: 00님 환영합니다. 또는 자동 로그인 되었습니다. 토스트 띄워주기
}
//TODO: access 재발급 요청
};

useEffect(() => {
Expand Down

0 comments on commit f8de14f

Please sign in to comment.