Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: 서버 로그인 로직 변경에 따른 AccessToken, RefeshToken 쿠키 세팅 제거 및 landingStatus 제거 #87

Merged
merged 23 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ec6dfe3
Merge branch 'dev' into chore/server-cookie
eugene028 Aug 5, 2024
99c1695
fix: 논리 테스트
eugene028 Aug 5, 2024
e7f5c18
fix: sentry 논리판단 되돌리기
eugene028 Aug 5, 2024
aa0d4ab
Merge branch 'dev' into chore/server-cookie
eugene028 Aug 5, 2024
6beb924
chore: console 테스트
eugene028 Aug 5, 2024
5265c04
Merge branch 'chore/server-cookie' of https://github.com/GDSC-Hongik/…
eugene028 Aug 5, 2024
171e886
fix: cookie base-url 상위 도메인으로 변경
eugene028 Aug 6, 2024
45766be
fix: landingStatus 로직 제거
eugene028 Aug 6, 2024
cebc9b2
fix: 메인화면 지원하기 버튼 dashboard로 라우트
eugene028 Aug 7, 2024
3d3bb87
fix:landingStatus 삭제 및 쿠키로직 수정
eugene028 Aug 7, 2024
d6c5642
fix: landingStatus 관련된 모든 로직 제거
eugene028 Aug 7, 2024
ad6d611
fix: 쿠키 판단 로직 재건
eugene028 Aug 7, 2024
dee2194
fix: 필요없는 guard 모두 삭제
eugene028 Aug 7, 2024
17a8c6d
fix: 리다이렉트 정리
eugene028 Aug 7, 2024
3fa3455
fix: 로그인 유지 시간 sessionStorage에서 확인
eugene028 Aug 7, 2024
f99e7ca
fix: 쿠키 관련 도메인 로직 모두 삭제
eugene028 Aug 7, 2024
ad7522f
fix: Cookie 관련 모든 로직 삭제
eugene028 Aug 7, 2024
2e70d63
fix: 빌드에러 터지는거 해결
eugene028 Aug 7, 2024
ca39fb5
fix: 서버에서 refresh갱신 실패할때 로그아웃 처리
eugene028 Aug 7, 2024
f93c7e9
fix: 403 에러 왔을때 세션 만료
eugene028 Aug 7, 2024
aada2ed
Merge branch 'dev' into chore/server-cookie
eugene028 Aug 7, 2024
628fb39
fix: 모집 기간 마감 예외처리
eugene028 Aug 7, 2024
1074b1e
fix: 파일 확장명 변경
eugene028 Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import styled from '@emotion/styled';
import { css } from '@emotion/react';
import GlobalSize from '@/constants/globalSize';
import { useNavigate } from 'react-router-dom';
import { getAuthRedirectPath } from '@/utils/auth';
import 'react-toastify/dist/ReactToastify.css';
import useLandingStatus from '@/hooks/zustand/useLandingStatus';
import RoutePath from './routes/routePath';

const IMG_SRC = [
'/onboarding/1.png',
Expand All @@ -29,7 +28,6 @@ const IMG_SRC = [

function App() {
const navigate = useNavigate();
const { landingStatus } = useLandingStatus();

return (
<Wrapper direction="column">
Expand Down Expand Up @@ -162,12 +160,8 @@ function App() {
<JoinText />
<OnboardingLogo2 />
<Space height={25} />
<ApplyButton
disabled={landingStatus === 'ONBOARDING_CLOSED'}
onClick={() => navigate(getAuthRedirectPath(landingStatus))}>
{landingStatus === 'ONBOARDING_CLOSED'
? '지금은 지원 기간이 아니에요'
: '가입하기'}
<ApplyButton onClick={() => navigate(RoutePath.Dashboard)}>
가입하기
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대시보드에서 Box uI를 통해서 현재 모집이 마감되었는지 아닌지를 판단하기 때문에, 가입하기로 통일하기로 했습니다

</ApplyButton>
<Space height={40} />
</BlueSection>
Expand Down
11 changes: 7 additions & 4 deletions src/apis/index.ts → src/apis/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BASE_URL, DEV_AUTH_TOKEN } from '@/constants/environment';
import useAuthToken from '@/hooks/auth/useAuthToken';
import axios from 'axios';

const apiClient = axios.create({
Expand All @@ -8,8 +7,12 @@ const apiClient = axios.create({
withCredentials: true
});

apiClient.defaults.headers.common['Authorization'] = DEV_AUTH_TOKEN
? `${DEV_AUTH_TOKEN}`
: `Bearer ${useAuthToken().accessToken}`;
export function setAuthHeader() {
if (DEV_AUTH_TOKEN) {
apiClient.defaults.headers.common['Authorization'] = DEV_AUTH_TOKEN;
}
}

setAuthHeader();

export default apiClient;
3 changes: 2 additions & 1 deletion src/components/ApiErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default function ApiErrorBoundary({ children }: PropsWithChildren) {
case 401:
case 403:
toast.error(message);
redirect(RoutePath.Index);
sessionStorage.setItem('isLogin', 'false');
redirect(RoutePath.Home);
break;
default:
toast.error(message);
Expand Down
24 changes: 18 additions & 6 deletions src/components/auth/guard/AuthAccessGuard.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import useLandingStatus from '@/hooks/zustand/useLandingStatus';
import { useEffect } from 'react';
import { Outlet } from 'react-router-dom';
import RoutePath from '@/routes/routePath';
import { isAuthenticated } from '@/utils/auth';
import { toast } from 'react-toastify';
import { useNavigate, Outlet } from 'react-router-dom';
import { useEffect, useState } from 'react';

export default function AuthAccessGuard() {
const { clearLandingStatus } = useLandingStatus();
const navigate = useNavigate();
const [redirect, setRedirect] = useState(false);

useEffect(() => {
clearLandingStatus();
if (!isAuthenticated()) {
toast.error('로그인이 필요한 서비스예요.');
setRedirect(true);
}
}, []);

return <Outlet />;
useEffect(() => {
if (redirect) {
navigate(RoutePath.Home);
}
}, [redirect, navigate]);

return isAuthenticated() ? <Outlet /> : null;
}
14 changes: 0 additions & 14 deletions src/components/auth/guard/MypageAccessGuard.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/auth/guard/OnboardingClosedAccessGuard.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/auth/guard/OnboardingNotOpenedAccessGuard.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/auth/guard/SignupAccessGuard.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/auth/guard/StudentVerificationAccessGuard.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/auth/guard/index.ts

This file was deleted.

19 changes: 9 additions & 10 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ import { Logo } from '@/assets/LogoIcon';
import { Flex } from '@/components/common/Wrapper';
import { JoinButton } from '@/components/layout/JoinButton';
import GlobalSize from '@/constants/globalSize';
import useLandingStatus from '@/hooks/zustand/useLandingStatus';
import RoutePath from '@/routes/routePath';
import { color } from 'wowds-tokens';
import { media } from '@/styles';
import { getAuthRedirectPath } from '@/utils/auth';
import styled from '@emotion/styled';
import { useLocation, useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { isAuthenticated } from '@/utils/auth';

//TODO: 백엔드 로그인 로직 수정 이후 반영 필요
export default function Header() {
const navigation = useNavigate();
const { pathname } = useLocation();
const { landingStatus } = useLandingStatus();

const handleClick = () => {
navigation(getAuthRedirectPath(landingStatus));
if (isAuthenticated()) navigation(RoutePath.Dashboard);
else {
navigation(RoutePath.GithubSignin);
}
};

return (
Expand All @@ -29,11 +30,9 @@ export default function Header() {
<HeaderLogo />
</Flex>
</LogoContainer>

{landingStatus === 'TO_DASHBOARD' && (
{isAuthenticated() ? (
<JoinButton onClick={handleClick}>내 정보</JoinButton>
)}
{pathname === '/' && landingStatus !== 'TO_DASHBOARD' && (
) : (
<JoinButton onClick={handleClick}>로그인/가입하기</JoinButton>
)}
</HeaderContainter>
Expand Down
5 changes: 2 additions & 3 deletions src/components/myPage/AssociateRequirementCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const AssociateRequirementCheck = ({
: '기본 회원 정보를 모두 입력했어요.'
}
onClick={() => {
if (infoStatus === 'PENDING')
navigate(RoutePath.AuthenticationProcess3_Signup);
if (infoStatus === 'PENDING') navigate(RoutePath.Signup);
}}
status={infoStatus === 'PENDING' ? 'error' : 'success'}
variant={infoStatus === 'PENDING' ? 'arrow' : 'text'}
Expand All @@ -53,7 +52,7 @@ const AssociateRequirementCheck = ({
/>
<Box
onClick={() => {
navigate(RoutePath.AuthenticationProcess2_StudentVerification);
navigate(RoutePath.StudentVerification);
}}
text={
univStatus === 'PENDING' ? (
Expand Down
5 changes: 1 addition & 4 deletions src/components/myPage/BasicUserInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { Flex, Text } from '@/components/common/Wrapper';
import { User } from '@/types/user';
import useLandingStatus from '@/hooks/zustand/useLandingStatus';
import { logout } from '@/utils/auth';
import { typography, color } from 'wowds-tokens';

import { useNavigate } from 'react-router-dom';

const BasicUserInfo = ({ member }: { member: User }) => {
const navigate = useNavigate();
const { clearLandingStatus } = useLandingStatus();

const handleLogoutClick = () => {
clearLandingStatus();
logout();

navigate('/');
location.reload();
};

return (
Expand Down
11 changes: 0 additions & 11 deletions src/constants/landingStatus.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/hooks/auth/useAuthToken.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/hooks/mutation/useCreateUserBasicInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { useNavigate } from 'react-router-dom';

export default function useCreateUserBasicInfo() {
const navigation = useNavigate();
// const { updateLandingStatue } = useLandingStatus();

const { mutate: createBasicInfo, ...rest } = useMutation({
mutationFn: createBasicInfoApi.BASIC_INFO,
onSuccess: () => {
// updateLandingStatue(LandingStatus.Dashboard);
navigation(RoutePath.Dashboard, { replace: true });
}
});
Expand Down
31 changes: 0 additions & 31 deletions src/hooks/zustand/useLandingStatus.ts

This file was deleted.

19 changes: 3 additions & 16 deletions src/pages/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import { GitHubButton } from '@/components/auth/GitHubButton';
import { Text } from '@/components/common/Wrapper';
import useLandingStatus from '@/hooks/zustand/useLandingStatus';
import RoutePath from '@/routes/routePath';
import { color, space } from 'wowds-tokens';
import { media } from '@/styles';
import { setCookie } from '@/utils/auth';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import GlobalSize from '@/constants/globalSize';
import { useEffect } from 'react';
import { Link } from 'react-router-dom';

/** 깃허브 로그인 및 가입하기 */
export const Auth = () => {
const { clearLandingStatus } = useLandingStatus();

useEffect(() => {
clearLandingStatus();
// 로그인을 위한 oauth-base-uri 쿠키 값 세팅

setCookie({
key: 'oauth-base-uri',
value: window.location.origin,
encoding: false
});
}, []);

const handleClick = () => {
//TODO: QA용으로 임시로 설정
sessionStorage.setItem('isLogin', 'true');

// GitHub 로그인 페이지로 직접 리다이렉트
setTimeout(function () {
document.location.href = RoutePath.AuthGithubLoginRedirect;
Expand Down
Loading
Loading