Commit b84511b5 authored by 우지원's avatar 우지원
Browse files

링크추가

parent c748afc4
import React from 'react' import React from 'react'
import { Navbar, Nav, Button } from 'react-bootstrap'; import { Navbar, Nav, Button } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { handleLogout } from '../utils/auth'; import { handleLogout } from '../utils/auth';
function Menu() { function Menu() {
...@@ -14,7 +15,9 @@ function Menu() { ...@@ -14,7 +15,9 @@ function Menu() {
<Nav.Link href="/profile">Profile</Nav.Link> <Nav.Link href="/profile">Profile</Nav.Link>
<Nav.Link href="/hello">Hello</Nav.Link> <Nav.Link href="/hello">Hello</Nav.Link>
</Nav> </Nav>
<Button onClick={() => handleLogout()} variant="light" className="ml-3">Logout</Button> <Link to="./login">
<Button onClick={() => handleLogout()} variant="light" className="ml-3">Logout</Button>
</Link>
</Navbar> </Navbar>
) )
} }
......
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import axios from 'axios' import axios from 'axios'
import { Button, Form, Container, Navbar, Alert } from 'react-bootstrap'; import { Button, Form, Container, Navbar, Alert } from 'react-bootstrap';
import catchErrors from '../utils/catchErrors'; import catchErrors from '../utils/catchErrors';
//import { Redirect } from 'react-router-dom'; import { Redirect } from 'react-router-dom';
const INIT_USER = { const INIT_USER = {
username: '', username: '',
...@@ -16,6 +16,7 @@ function SingUp() { ...@@ -16,6 +16,7 @@ function SingUp() {
const [user, setUser] = useState(INIT_USER) const [user, setUser] = useState(INIT_USER)
const [error, setError] = useState('') const [error, setError] = useState('')
const [disabled, setDisabled] = useState(true) const [disabled, setDisabled] = useState(true)
const [success, setSucces] = useState(false)
useEffect(() => { useEffect(() => {
const isUser = Object.values(user).every(el => Boolean(el)) const isUser = Object.values(user).every(el => Boolean(el))
...@@ -62,15 +63,16 @@ function SingUp() { ...@@ -62,15 +63,16 @@ function SingUp() {
// ?????????hash 처리된 password가 저장되지 않았음 // ?????????hash 처리된 password가 저장되지 않았음
// setUser(INIT_USER) // setUser(INIT_USER)
setSucces(true)
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
} }
} }
// if (success) { if (success) {
// console.log('success', success) console.log('success', success)
// return <Redirect to='/login'/> return <Redirect to='/login' />
// } }
return ( return (
......
...@@ -49,14 +49,14 @@ const login = async (req, res) => { ...@@ -49,14 +49,14 @@ const login = async (req, res) => {
} catch (error) { } catch (error) {
//알수없는 모든 에러발생시 처리 //알수없는 모든 에러발생시 처리
console.log(error) console.log(error)
res.status(500).send('로그인 에러') res.status(500).send('로그인 에러가 발생하였습니다')
} }
} }
const logout = (req, res) => { const logout = (req, res) => {
res.clearCookie('token') res.clearCookie('token')
res.send('Logout Successful') res.send('로그아웃 되었습니다')
} }
export default { login, logout } export default { login, logout }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment