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