diff --git a/frontend/src/GlobalErrorBoundary.tsx b/frontend/src/GlobalErrorBoundary.tsx index ceacdde..3f94c15 100644 --- a/frontend/src/GlobalErrorBoundary.tsx +++ b/frontend/src/GlobalErrorBoundary.tsx @@ -2,8 +2,13 @@ import { PropsWithChildren } from "react"; import { ErrorBoundary, FallbackProps } from "react-error-boundary"; import ErrorPage from "./pages/error/CommonErrorPage"; import AuthErrorPage from "./pages/error/AuthErrorPage"; +import { ERROR_MESSAGE } from "./constants/error"; +import NotPermittedPage from "./pages/error/NotPermittedPage"; const GlobalErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => { + if (error.message === ERROR_MESSAGE.NOT_PERMITTED) + return ; + if (error.response.status === 401) return ; return ; }; diff --git a/frontend/src/apis/api/loginAPI.ts b/frontend/src/apis/api/loginAPI.ts index c9bef57..09e58ff 100644 --- a/frontend/src/apis/api/loginAPI.ts +++ b/frontend/src/apis/api/loginAPI.ts @@ -10,9 +10,7 @@ import { useNavigate } from "react-router-dom"; import { authAPI, setAccessToken } from "../utils/authAPI"; export const getLoginURL = async () => { - const response = await baseAPI.get( - API_URL.GITHUB_OAUTH_URL - ); + const response = await baseAPI.get(API_URL.GITHUB_OAUTH_URL); return response.data.authUrl; }; @@ -40,6 +38,7 @@ export const postLogout = async () => { if (response.status === 200) { setAccessToken(undefined); + window.localStorage.clear(); return response; } }; diff --git a/frontend/src/constants/error.ts b/frontend/src/constants/error.ts new file mode 100644 index 0000000..07b78dc --- /dev/null +++ b/frontend/src/constants/error.ts @@ -0,0 +1,3 @@ +export const ERROR_MESSAGE = { + NOT_PERMITTED: "허용되지 않는 접근입니다.", +}; diff --git a/frontend/src/constants/path.ts b/frontend/src/constants/path.ts index 8e8ec49..420da73 100644 --- a/frontend/src/constants/path.ts +++ b/frontend/src/constants/path.ts @@ -13,7 +13,7 @@ export const API_URL = { export const ROUTER_URL = { ROOT: "/", - TEMP: "/temp", + TEMP: "/", LOGIN: "/login", SIGNUP: "/signup", AUTH: "/auth/github/callback", diff --git a/frontend/src/pages/TempHomepage.tsx b/frontend/src/pages/TempHomepage.tsx index b173596..44d5b5d 100644 --- a/frontend/src/pages/TempHomepage.tsx +++ b/frontend/src/pages/TempHomepage.tsx @@ -1,5 +1,5 @@ import { useEffect } from "react"; -import { Link } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; import React from "react"; import { ROUTER_URL } from "../constants/path"; @@ -10,6 +10,10 @@ const TempHomepage = () => { console.log(await response.json()); }); }); + const navigate = useNavigate(); + const navigateToSignupPage = () => { + navigate(ROUTER_URL.SIGNUP, { state: { tempIdToken: "hello world" } }); + }; return (
@@ -26,6 +30,11 @@ const TempHomepage = () => { Sign up +
  • + +
  • Projects diff --git a/frontend/src/pages/account/SignupPage.tsx b/frontend/src/pages/account/SignupPage.tsx index 8e4f1f5..c0d9456 100644 --- a/frontend/src/pages/account/SignupPage.tsx +++ b/frontend/src/pages/account/SignupPage.tsx @@ -2,6 +2,8 @@ import { useState } from "react"; import SignupSideBar from "../../components/account/SignupSideBar"; import SignupMainSection from "../../components/account/SignupMainSection"; import { SIGNUP_STEP } from "../../constants/account"; +import { useLocation } from "react-router-dom"; +import { ERROR_MESSAGE } from "../../constants/error"; const SignupPage = () => { const [currentStep, setCurrentStep] = useState<{ @@ -9,16 +11,15 @@ const SignupPage = () => { NAME: string; }>(SIGNUP_STEP.STEP1); + const location = useLocation(); + if (location.state ? false : true) { + throw Error(ERROR_MESSAGE.NOT_PERMITTED); + } + return (
    - - + +
    ); }; diff --git a/frontend/src/pages/error/NotPermittedPage.tsx b/frontend/src/pages/error/NotPermittedPage.tsx new file mode 100644 index 0000000..3b311e2 --- /dev/null +++ b/frontend/src/pages/error/NotPermittedPage.tsx @@ -0,0 +1,22 @@ +import { FallbackProps } from "react-error-boundary"; +import { useNavigate } from "react-router-dom"; +import { ROUTER_URL } from "../../constants/path"; + +const NotPermittedPage = ({ error, resetErrorBoundary }: FallbackProps) => { + const navigate = useNavigate(); + const redirectTempPage = () => { + resetErrorBoundary(); + navigate(ROUTER_URL.TEMP); + }; + return ( +
    +

    Error 발생

    +

    error : {error.message}

    + +
    + ); +}; + +export default NotPermittedPage;