정의왕

Fix file

...@@ -17,18 +17,19 @@ router.post('/',(req,res)=>{ ...@@ -17,18 +17,19 @@ router.post('/',(req,res)=>{
17 //id와 일치하는 정보가 없는경우 17 //id와 일치하는 정보가 없는경우
18 if(result === null || result === undefined){ 18 if(result === null || result === undefined){
19 console.log("일치하는 id가 없습니다.") 19 console.log("일치하는 id가 없습니다.")
20 - res.sendStatus(401); 20 + res.status(401).send("idError");
21 } 21 }
22 //비밀번호 불일치 22 //비밀번호 불일치
23 else if(result.dataValues.pw != req.body.Password){ 23 else if(result.dataValues.pw != req.body.Password){
24 console.log("일치하는 pw가 없습니다.") 24 console.log("일치하는 pw가 없습니다.")
25 - res.sendStatus(401); 25 + res.status(401).send("pwError");
26 } 26 }
27 else if(result.dataValues.pw == req.body.Password){ 27 else if(result.dataValues.pw == req.body.Password){
28 req.session.id = result.dataValues.id; 28 req.session.id = result.dataValues.id;
29 req.session.name = result.dataValues.name; 29 req.session.name = result.dataValues.name;
30 req.session.personality = result.dataValues.personality; 30 req.session.personality = result.dataValues.personality;
31 req.session.status = result.dataValues.status; 31 req.session.status = result.dataValues.status;
32 + req.session.isAuthorized = true;
32 console.log("Login"); 33 console.log("Login");
33 res.sendStatus(200); 34 res.sendStatus(200);
34 } 35 }
......
1 -import {BrowserRouter as Router, Route, Routes} from "react-router-dom"; 1 +import {BrowserRouter as Redirect, Router, Route, Routes} from "react-router-dom";
2 import MainPage from "./component/views/MainPage/MainPage"; 2 import MainPage from "./component/views/MainPage/MainPage";
3 import LoginPage from "./component/views/LoginPage/LoginPage"; 3 import LoginPage from "./component/views/LoginPage/LoginPage";
4 import RegisterPage from "./component/views/RegisterPage/RegisterPage"; 4 import RegisterPage from "./component/views/RegisterPage/RegisterPage";
5 import "./static/fonts/font.css"; 5 import "./static/fonts/font.css";
6 -import LandingPage from "./component/views/LandingPage/LandingPage";
7 6
8 function App () { 7 function App () {
9 let isAuthorized = sessionStorage.getItem("isAuthorized"); // 8 let isAuthorized = sessionStorage.getItem("isAuthorized"); //
10 return ( 9 return (
11 <Router> 10 <Router>
12 <div> 11 <div>
13 - {!isAuthorized ? <Redirect to="/login" /> : <Redirect to="/" />} 12 + {!isAuthorized ? <Redirect to="/login" /> : <Redirect to="/main" />}
14 <Routes> 13 <Routes>
15 - <Route exact path = "/" element={<LandingPage/>}/>
16 <Route exact path = "/login" element={<LoginPage/>}/> 14 <Route exact path = "/login" element={<LoginPage/>}/>
17 <Route exact path = "/main" element={<MainPage/>}/> 15 <Route exact path = "/main" element={<MainPage/>}/>
18 <Route exact path = "/register" element={<RegisterPage/>}/> 16 <Route exact path = "/register" element={<RegisterPage/>}/>
......
1 -import React from 'react'
2 -//import axios from 'axios'
3 -// import { response } from 'express'
4 -
5 -function LandingPage() {
6 -
7 - // useEffect(() => {
8 - // axios.get('/api/hello')
9 - // .then(response => console.log(response.data))
10 - // }, [])
11 -
12 - return (
13 - <div>
14 - LandingPage
15 - </div>
16 - )
17 -}
18 -
19 -export default LandingPage
20 -