Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
students
messenger
Commits
aa88e353
Commit
aa88e353
authored
Jan 14, 2021
by
우지원
Browse files
menu, loginpage 수정
parent
7566e570
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/src/Components/Menu.js
View file @
aa88e353
...
...
@@ -3,23 +3,18 @@ import React, { useState, useEffect } from 'react';
import
{
Navbar
,
Nav
,
Button
}
from
'
react-bootstrap
'
;
import
{
handleLogout
,
isAuthenticated
}
from
'
../utils/auth
'
;
const
INIT_USER
=
{
username
:
''
}
function
Menu
()
{
const
user
=
isAuthenticated
()
const
[
userName
,
setUsername
]
=
useState
(
INIT_USER
)
const
[
userName
,
setUsername
]
=
useState
(
''
)
async
function
getLoginedUser
()
{
const
userId
=
localStorage
.
getItem
(
'
user
'
)
const
response
=
await
axios
.
get
(
`/users/
${
userId
}
`
)
console
.
log
(
response
.
data
.
username
)
const
resName
=
response
.
data
.
username
// const resName = JSON.stringify(response.data.username)
// console.log(resName)
//const resName = JSON.stringify(response.data.username)
console
.
log
(
resName
)
setUsername
(
resName
)
}
console
.
log
(
userName
)
...
...
client/src/Pages/LogInPage.js
View file @
aa88e353
...
...
@@ -12,7 +12,7 @@ const INIT_USER = {
}
function
LogIn
()
{
const
[
validated
,
setValidated
]
=
useState
(
false
);
//
const [validated, setValidated] = useState(false);
const
[
user
,
setUser
]
=
useState
(
INIT_USER
)
//로딩, 에러, diserved 상태 넣어야됨.
const
[
disabled
,
setDisabled
]
=
useState
(
true
)
...
...
@@ -73,7 +73,7 @@ function LogIn() {
<>
<
Menu
/>
<
Form
noValidate
validated
=
{
validated
}
onSubmit
=
{
handleSubmit
}
className
=
'
vh-100 flex-column align-items-center justify-content-center mt-2
'
>
<
Form
onSubmit
=
{
handleSubmit
}
className
=
'
vh-100 flex-column align-items-center justify-content-center mt-2
'
>
<
Container
className
=
"
d-flex justify-content-center
"
>
<
div
className
=
"
mt-5 p-5 shadow w-75
"
>
...
...
client/src/utils/auth.js
View file @
aa88e353
...
...
@@ -4,6 +4,7 @@ import axios from "axios"
export
function
handleLogin
(
userId
)
{
localStorage
.
setItem
(
'
user
'
,
userId
)
}
export
async
function
handleLogout
()
{
localStorage
.
removeItem
(
'
user
'
)
await
axios
.
get
(
'
/auth/logout
'
)
...
...
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