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

링크추가

parent c748afc4
import React from 'react'
import { Navbar, Nav, Button } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { handleLogout } from '../utils/auth';
function Menu() {
......@@ -14,7 +15,9 @@ function Menu() {
<Nav.Link href="/profile">Profile</Nav.Link>
<Nav.Link href="/hello">Hello</Nav.Link>
</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>
)
}
......
......@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import axios from 'axios'
import { Button, Form, Container, Navbar, Alert } from 'react-bootstrap';
import catchErrors from '../utils/catchErrors';
//import { Redirect } from 'react-router-dom';
import { Redirect } from 'react-router-dom';
const INIT_USER = {
username: '',
......@@ -16,6 +16,7 @@ function SingUp() {
const [user, setUser] = useState(INIT_USER)
const [error, setError] = useState('')
const [disabled, setDisabled] = useState(true)
const [success, setSucces] = useState(false)
useEffect(() => {
const isUser = Object.values(user).every(el => Boolean(el))
......@@ -62,15 +63,16 @@ function SingUp() {
// ?????????hash 처리된 password가 저장되지 않았음
// setUser(INIT_USER)
setSucces(true)
} catch (error) {
catchErrors(error, setError)
}
}
// if (success) {
// console.log('success', success)
// return <Redirect to='/login'/>
// }
if (success) {
console.log('success', success)
return <Redirect to='/login' />
}
return (
......
......@@ -49,14 +49,14 @@ const login = async (req, res) => {
} catch (error) {
//알수없는 모든 에러발생시 처리
console.log(error)
res.status(500).send('로그인 에러')
res.status(500).send('로그인 에러가 발생하였습니다')
}
}
const logout = (req, res) => {
res.clearCookie('token')
res.send('Logout Successful')
res.send('로그아웃 되었습니다')
}
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