Showing
3 changed files
with
21 additions
and
2 deletions
... | @@ -6,9 +6,11 @@ import "./static/fonts/font.css"; | ... | @@ -6,9 +6,11 @@ import "./static/fonts/font.css"; |
6 | import LandingPage from "./component/views/LandingPage/LandingPage"; | 6 | import LandingPage from "./component/views/LandingPage/LandingPage"; |
7 | 7 | ||
8 | function App () { | 8 | function App () { |
9 | + let isAuthorized = sessionStorage.getItem("isAuthorized"); // | ||
9 | return ( | 10 | return ( |
10 | <Router> | 11 | <Router> |
11 | <div> | 12 | <div> |
13 | + {!isAuthorized ? <Redirect to="/login" /> : <Redirect to="/" />} | ||
12 | <Routes> | 14 | <Routes> |
13 | <Route exact path = "/" element={<LandingPage/>}/> | 15 | <Route exact path = "/" element={<LandingPage/>}/> |
14 | <Route exact path = "/login" element={<LoginPage/>}/> | 16 | <Route exact path = "/login" element={<LoginPage/>}/> | ... | ... |
1 | import React, {useState} from "react"; | 1 | import React, {useState} from "react"; |
2 | import "../style/LoginPage.scss"; | 2 | import "../style/LoginPage.scss"; |
3 | +import Axios from 'axios' | ||
3 | import { Icon, Input } from "semantic-ui-react" | 4 | import { Icon, Input } from "semantic-ui-react" |
4 | import { useNavigate } from "react-router-dom"; | 5 | import { useNavigate } from "react-router-dom"; |
5 | 6 | ||
... | @@ -19,7 +20,23 @@ function LoginPage(props) { | ... | @@ -19,7 +20,23 @@ function LoginPage(props) { |
19 | event.preventDefault(); | 20 | event.preventDefault(); |
20 | console.log("ID", Id); | 21 | console.log("ID", Id); |
21 | console.log("Password", Password); | 22 | console.log("Password", Password); |
22 | - | 23 | + Axios.post('/api/login',{ |
24 | + Id, | ||
25 | + Password, | ||
26 | + }) | ||
27 | + .then((res)=>{ | ||
28 | + if(res.status === 200){ | ||
29 | + alert("성공적으로 로그인하였습니다.") | ||
30 | + navigate('/main') | ||
31 | + } | ||
32 | + }).catch((error) => { | ||
33 | + if(error.response.data === 'idError'){ | ||
34 | + alert("존재하지 않는 아이디입니다.") | ||
35 | + } | ||
36 | + else if(error.response.data === 'pwError'){ | ||
37 | + alert("잘못된 비밀번호입니다.") | ||
38 | + } | ||
39 | + }) | ||
23 | }; | 40 | }; |
24 | const goToRegister = () => { | 41 | const goToRegister = () => { |
25 | navigate('/register'); | 42 | navigate('/register'); | ... | ... |
... | @@ -45,9 +45,9 @@ function RegisterPage(props) { | ... | @@ -45,9 +45,9 @@ function RegisterPage(props) { |
45 | } | 45 | } |
46 | }).catch((error) => { | 46 | }).catch((error) => { |
47 | console.log(error.response) | 47 | console.log(error.response) |
48 | + alert("중복된 아이디입니다.") | ||
48 | }) | 49 | }) |
49 | } | 50 | } |
50 | - | ||
51 | },[Id, Password, Personality, PasswordCheck]) | 51 | },[Id, Password, Personality, PasswordCheck]) |
52 | return ( | 52 | return ( |
53 | <div id="Register"> | 53 | <div id="Register"> | ... | ... |
-
Please register or login to post a comment