From 9353d208877737c49233e03b5479206785f45a8f Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 15:55:08 +0900 Subject: [PATCH 1/9] =?UTF-8?q?chore:=20gitignore=EC=97=90=20SLL=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=EC=84=9C=20=EA=B4=80=EB=A0=A8=20=ED=82=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f66c490a5..7d19c014c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,8 @@ ### Environment Variable ### .env + +*.crt +*.csr +*.key +*.pem From 3783fd5fc21a2f248584ff1523e563dc7218a05b Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:03:47 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix(authentication):=20useCheckLoginState?= =?UTF-8?q?=20=ED=9B=85=EC=97=90=EC=84=9C=20=ED=86=A0=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/authentication/useCheckLoginState.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/hooks/authentication/useCheckLoginState.ts b/frontend/src/hooks/authentication/useCheckLoginState.ts index eee293076..8ab2a5545 100644 --- a/frontend/src/hooks/authentication/useCheckLoginState.ts +++ b/frontend/src/hooks/authentication/useCheckLoginState.ts @@ -18,8 +18,6 @@ export const useCheckLoginState = () => { useEffect(() => { if (isError) { - infoAlert('로그인을 해주세요'); - handleLoginNavigate(); handleLoginState(false); } From c364298574a87d96a596c0f905f273179b8166ac Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:05:45 +0900 Subject: [PATCH 3/9] =?UTF-8?q?refactor(Header):=20Header=EC=97=90?= =?UTF-8?q?=EC=84=9C=EC=9D=98=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=B2=B4=ED=81=AC=20=ED=9B=85=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Header/Header.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header/Header.tsx index ed0b79a44..3e6f1d52f 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -2,7 +2,6 @@ import { Link } from 'react-router-dom'; import { logoIcon, newTemplateIcon, userMenuIcon } from '@/assets/images'; import { Button, Flex, Heading, Text } from '@/components'; -import { useCheckLoginState } from '@/hooks/authentication'; import { useAuth } from '@/hooks/authentication/useAuth'; import { useLogoutMutation } from '@/queries/authentication/useLogoutMutation'; import { theme } from '../../style/theme'; @@ -11,8 +10,6 @@ import * as S from './Header.style'; const Header = ({ headerRef }: { headerRef: React.RefObject }) => { const { isLogin } = useAuth(); - useCheckLoginState(); - return ( From 7d37f43bb4f605f5c149c0693a9761334c63d065 Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:07:13 +0900 Subject: [PATCH 4/9] =?UTF-8?q?refactor(authentication):=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=84=B1=EA=B3=B5=20=EC=8B=9C,=20useAuth?= =?UTF-8?q?=EC=9D=98=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/authentication/useLoginForm.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/hooks/authentication/useLoginForm.ts b/frontend/src/hooks/authentication/useLoginForm.ts index b2ba1aec0..be2b964e4 100644 --- a/frontend/src/hooks/authentication/useLoginForm.ts +++ b/frontend/src/hooks/authentication/useLoginForm.ts @@ -5,12 +5,15 @@ import { postLogin } from '@/api/authentication'; import { ToastContext } from '@/context/ToastContext'; import { useInputWithValidate } from '../useInputWithValidate'; import useCustomContext from '../utils/useCustomContext'; +import { useAuth } from './useAuth'; import { validateEmail, validatePassword } from './validates'; export const useLoginForm = () => { const navigate = useNavigate(); const { failAlert, successAlert } = useCustomContext(ToastContext); + const { handleLoginState } = useAuth(); + const { value: email, errorMessage: emailError, @@ -38,6 +41,7 @@ export const useLoginForm = () => { return; } + handleLoginState(true); navigate('/'); successAlert('로그인 성공!'); } From e8643766bc525d4f17e7308f6048634438a5be34 Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:07:53 +0900 Subject: [PATCH 5/9] =?UTF-8?q?feat(routes):=20=EB=AA=A8=EB=93=A0=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EC=97=90=20AuthGuard,=20GuestGuard=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/routes/AuthGuard.tsx | 25 +++++++++++++++++++++++ frontend/src/routes/GuestGuard.tsx | 25 +++++++++++++++++++++++ frontend/src/routes/router.tsx | 32 +++++++++++++++++++++++++----- 3 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 frontend/src/routes/AuthGuard.tsx create mode 100644 frontend/src/routes/GuestGuard.tsx diff --git a/frontend/src/routes/AuthGuard.tsx b/frontend/src/routes/AuthGuard.tsx new file mode 100644 index 000000000..9d417bd97 --- /dev/null +++ b/frontend/src/routes/AuthGuard.tsx @@ -0,0 +1,25 @@ +import { ReactNode } from 'react'; +import { Navigate } from 'react-router-dom'; + +import { ToastContext } from '@/context/ToastContext'; +import { useAuth } from '@/hooks/authentication/useAuth'; +import useCustomContext from '@/hooks/utils/useCustomContext'; + +type AuthGuardProps = { + children: ReactNode; +}; + +const AuthGuard = ({ children }: AuthGuardProps) => { + const { isLogin } = useAuth(); + const { infoAlert } = useCustomContext(ToastContext); + + if (isLogin) { + infoAlert('이미 로그인된 사용자입니다.'); + + return ; + } + + return children; +}; + +export default AuthGuard; diff --git a/frontend/src/routes/GuestGuard.tsx b/frontend/src/routes/GuestGuard.tsx new file mode 100644 index 000000000..787215baa --- /dev/null +++ b/frontend/src/routes/GuestGuard.tsx @@ -0,0 +1,25 @@ +import { ReactNode } from 'react'; +import { Navigate } from 'react-router-dom'; + +import { ToastContext } from '@/context/ToastContext'; +import { useAuth } from '@/hooks/authentication/useAuth'; +import useCustomContext from '@/hooks/utils/useCustomContext'; + +type GuestGuardProps = { + children: ReactNode; +}; + +const GuestGuard = ({ children }: GuestGuardProps) => { + const { isLogin } = useAuth(); + const { infoAlert } = useCustomContext(ToastContext); + + if (!isLogin) { + infoAlert('로그인을 해주세요.'); + + return ; + } + + return children; +}; + +export default GuestGuard; diff --git a/frontend/src/routes/router.tsx b/frontend/src/routes/router.tsx index 0ad118ecb..6477522cb 100644 --- a/frontend/src/routes/router.tsx +++ b/frontend/src/routes/router.tsx @@ -2,6 +2,8 @@ import { createBrowserRouter } from 'react-router-dom'; import { Layout } from '@/components'; import { TemplatePage, MyTemplatePage, TemplateUploadPage, SignupPage, LoginPage } from '@/pages'; +import AuthGuard from './AuthGuard'; +import GuestGuard from './GuestGuard'; const router = createBrowserRouter([ { @@ -9,23 +11,43 @@ const router = createBrowserRouter([ children: [ { path: '/', - element: , + element: ( + + , + + ), }, { path: 'templates/:id', - element: , + element: ( + + + + ), }, { path: 'templates/upload', - element: , + element: ( + + + + ), }, { path: 'signup', - element: , + element: ( + + + + ), }, { path: 'login', - element: , + element: ( + + , + + ), }, ], }, From 8c3c9f5e47a6abbb71b8a7166753ec7e483aecd1 Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:38:57 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat(Header):=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=B2=84=ED=8A=BC=20->=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=95=84=EC=9B=83=20=EB=B2=84=ED=8A=BC=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=90=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Header/Header.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header/Header.tsx index 3e6f1d52f..6f885e7e5 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -1,6 +1,6 @@ import { Link } from 'react-router-dom'; -import { logoIcon, newTemplateIcon, userMenuIcon } from '@/assets/images'; +import { logoIcon, newTemplateIcon } from '@/assets/images'; import { Button, Flex, Heading, Text } from '@/components'; import { useAuth } from '@/hooks/authentication/useAuth'; import { useLogoutMutation } from '@/queries/authentication/useLogoutMutation'; @@ -25,7 +25,7 @@ const Header = ({ headerRef }: { headerRef: React.RefObject }) = 새 템플릿 - {isLogin ? : } + {isLogin ? : } @@ -51,7 +51,7 @@ const NavOption = ({ route, name }: { route: string; name: string }) => ( ); -const UserMenuButton = () => { +const LogoutButton = () => { const { mutateAsync } = useLogoutMutation(); const handleLogoutButton = async () => { @@ -59,9 +59,9 @@ const UserMenuButton = () => { }; return ( - - 사용자 메뉴 - + ); }; From aaea1629a3c2c6412cdff4d293fe40c1f734cf89 Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:39:28 +0900 Subject: [PATCH 7/9] =?UTF-8?q?refactor(workflows):=20frontend=5Fcd=20-=20?= =?UTF-8?q?Sentry=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/frontend_cd.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/frontend_cd.yml b/.github/workflows/frontend_cd.yml index 5571b95cd..652a80e76 100644 --- a/.github/workflows/frontend_cd.yml +++ b/.github/workflows/frontend_cd.yml @@ -23,10 +23,16 @@ jobs: run: | echo "REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}" > ${{ env.frontend-directory }}/.env.production echo "REACT_APP_BASE_URL=${{ secrets.REACT_APP_BASE_URL }}" >> ${{ env.frontend-directory }}/.env.production + echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> ${{ env.frontend-directory }}/.env.production + echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> ${{ env.frontend-directory }}/.env.production + echo "SENTRY_DSN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> ${{ env.frontend-directory }}/.env.sentry-build-plugin - name: Set environment file permissions run: chmod 644 ${{ env.frontend-directory }}/.env.production + - name: Set Sentry environment file permissions + run: chmod 644 ${{ env.frontend-directory }}/.env.sentry-build-plugin + - name: Install Dependencies run: npm install working-directory: ${{ env.frontend-directory }} From 5aaafd10cbe013b06bf56a4fee34b1f7410dfeed Mon Sep 17 00:00:00 2001 From: jayming66 Date: Wed, 7 Aug 2024 17:50:28 +0900 Subject: [PATCH 8/9] =?UTF-8?q?design(LoginPage):=20'=EA=B3=84=EC=A0=95?= =?UTF-8?q?=EC=9D=B4=20=EC=97=86=EC=9C=BC=EC=8B=A0=EA=B0=80=EC=9A=94'=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=EC=9D=98=20align,=20size,=20gap=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/LoginPage/LoginPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/LoginPage/LoginPage.tsx b/frontend/src/pages/LoginPage/LoginPage.tsx index 739eb0bd5..c0e16ec18 100644 --- a/frontend/src/pages/LoginPage/LoginPage.tsx +++ b/frontend/src/pages/LoginPage/LoginPage.tsx @@ -43,8 +43,8 @@ const LoginPage = () => { - - 계정이 없으신가요? + + 계정이 없으신가요? - - 이미 계정이 있으신가요? + + 이미 계정이 있으신가요?