Commit 74f2c338 authored by kusang96's avatar kusang96
Browse files

dd

parent 4815e070
...@@ -5,7 +5,6 @@ import Pagination from '../Components/Pagination'; ...@@ -5,7 +5,6 @@ import Pagination from '../Components/Pagination';
import axios from 'axios'; import axios from 'axios';
import catchError from '../utils/catchErrors'; import catchError from '../utils/catchErrors';
import { isAuthenticated } from '../utils/auth'; import { isAuthenticated } from '../utils/auth';
import catchError from '../utils/catchErrors';
import { Container, Row, Col, Form, FormControl, Button, Dropdown } from 'react-bootstrap'; import { Container, Row, Col, Form, FormControl, Button, Dropdown } from 'react-bootstrap';
function ProductsList({ match }) { function ProductsList({ match }) {
......
import axios from "axios"; import axios from "axios";
export function handleLogin({ userId, role, name }) { export function handleLogin({ userId, role, name, tel }) {
localStorage.setItem('id', userId) localStorage.setItem('id', userId)
localStorage.setItem('role', role) localStorage.setItem('role', role)
localStorage.setItem('name', name) localStorage.setItem('name', name)
localStorage.setItem('tel', tel)
} }
export async function handleLogout() { export async function handleLogout() {
localStorage.removeItem('id') localStorage.clear()
localStorage.removeItem('role')
localStorage.removeItem('name')
await axios.get('/api/auth/logout') await axios.get('/api/auth/logout')
window.location.href = '/' window.location.href = '/'
} }
......
...@@ -7,7 +7,7 @@ const login = async (req, res) => { ...@@ -7,7 +7,7 @@ const login = async (req, res) => {
const { id, password } = req.body const { id, password } = req.body
console.log(id, password) console.log(id, password)
try { try {
const user = await User.findOne({ id }).select('password role name') const user = await User.findOne({ id }).select('password role name tel')
console.log('u=', user) console.log('u=', user)
if (!user) { if (!user) {
return res.status(404).send(`${id}가 존재하지 않습니다.`) return res.status(404).send(`${id}가 존재하지 않습니다.`)
...@@ -23,7 +23,7 @@ const login = async (req, res) => { ...@@ -23,7 +23,7 @@ const login = async (req, res) => {
httpOnly: true, httpOnly: true,
secure: config.env === 'production' secure: config.env === 'production'
}) })
res.json({ userId: user._id, role: user.role, name: user.name }) res.json({ userId: user._id, role: user.role, name: user.name, tel: user.tel })
} else { } else {
res.status(401).send('비밀번호가 일치하지 않습니다.') res.status(401).send('비밀번호가 일치하지 않습니다.')
......
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