Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
reservation-service
Commits
7b01b433
Commit
7b01b433
authored
Sep 27, 2020
by
CHAERIN KIM
Browse files
예진언니 menu 요청 적용
parent
f54a6948
Changes
3
Show whitespace changes
Inline
Side-by-side
server/client/src/Components/Menu.js
View file @
7b01b433
...
...
@@ -8,11 +8,12 @@ const Nav = styled.nav`
function
Menu
()
{
const
[
state
,
setState
]
=
useState
()
const
name
=
localStorage
.
getItem
(
'
name
'
);
if
(
state
)
return
<
Redirect
to
=
"
/
"
/>
;
function
logout
()
{
localStorage
.
removeItem
(
'
token
'
);
localStorage
.
clear
(
);
alert
(
"
로그아웃 되었습니다.
"
);
setState
(
true
);
}
...
...
@@ -39,6 +40,7 @@ function Menu() {
<
/li
>
<
/ul
>
<
div
>
<
div
>
{
name
}
님
안녕하세요
.
<
/div
>
<
button
onClick
=
{
logout
}
type
=
"
button
"
>
로그아웃
<
/button
>
<
button
><
Link
to
=
"
/signup
"
>
회원가입
<
/Link></
button
>
<
/div
>
...
...
server/client/src/Pages/LoginPage.js
View file @
7b01b433
...
...
@@ -44,10 +44,9 @@ function Login() {
data
:
values
,
}).
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
로그인이 완료되었습니다!
"
)
localStorage
.
setItem
(
'
token
'
,
res
.
data
.
token
);
localStorage
.
setItem
(
'
id
'
,
res
.
data
.
users
.
_id
);
localStorage
.
setItem
(
'
name
'
,
res
.
data
.
users
.
name
);
setState
(
true
);
})
.
catch
(
err
=>
{
...
...
server/routes/login.js
View file @
7b01b433
...
...
@@ -20,7 +20,7 @@ router.get('/', function (req, res, next) {
router
.
post
(
'
/
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/login post request
'
,
req
.
body
)
User
.
findOne
({
id
:
req
.
body
.
id
},
'
id password
'
,
function
(
err
,
users
)
{
User
.
findOne
({
id
:
req
.
body
.
id
},
'
id password
name
'
,
function
(
err
,
users
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
!
users
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment