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
bora-it
Commits
4a23dcaa
Commit
4a23dcaa
authored
Jul 27, 2021
by
우지원
Browse files
Merge remote-tracking branch 'origin/seoyeon2' into jiweon827
parents
6d97fb5a
ac15b407
Changes
4
Show whitespace changes
Inline
Side-by-side
client/src/components/Header.js
View file @
4a23dcaa
import
{
Link
}
from
'
react-router-dom
'
import
{
Link
}
from
'
react-router-dom
'
import
{
handleLogout
}
from
'
../context/auth
'
const
Header
=
()
=>
{
const
Header
=
()
=>
{
return
(
return
(
<
div
>
<
div
>
...
@@ -48,11 +50,16 @@ const Header = () => {
...
@@ -48,11 +50,16 @@ const Header = () => {
<
/div
>
<
/div
>
<
div
className
=
"
row mb-3
"
>
<
div
className
=
"
row mb-3
"
>
<
div
className
=
"
d-flex justify-content-evenly
"
>
<
div
className
=
"
d-flex justify-content-evenly
"
>
{
/* <Link to="/user"> */
}
<
Link
to
=
"
/
"
className
=
"
col-2 p-1 btn btn-primary
"
>
<
button
type
=
"
submit
"
className
=
"
col-2 p-1 btn btn-primary
"
>
<
button
type
=
"
submit
"
className
=
"
btn btn-primary
"
onClick
=
{()
=>
handleLogout
()}
data
-
bs
-
dismiss
=
"
modal
"
>
예
예
<
/button
>
<
/button
>
{
/*
</Link>
*/
}
<
/Link
>
<
button
<
button
type
=
"
submit
"
type
=
"
submit
"
className
=
"
col-2 p-1 btn btn-primary
"
className
=
"
col-2 p-1 btn btn-primary
"
...
...
client/src/components/Login.js
View file @
4a23dcaa
import
{
useEffect
,
useState
}
from
'
react
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
Redirect
}
from
'
react-router-dom
'
import
{
Redirect
}
from
'
react-router-dom
'
import
userApi
from
'
../apis/user.api
'
import
userApi
from
'
../apis/user.api
'
// import { useAuth } from '../context/auth_context'
import
catchErrors
from
"
../context/catchError
"
;
import
catchErrors
from
"
../context/catchError
"
;
import
{
handleLogin
}
from
'
../context/auth
'
;
const
INIT_USER
=
{
const
INIT_USER
=
{
email
:
''
,
email
:
''
,
password
:
''
,
password
:
''
,
...
@@ -33,6 +33,7 @@ const Login = () => {
...
@@ -33,6 +33,7 @@ const Login = () => {
// setError("");
// setError("");
const
data
=
await
userApi
.
login
(
user
)
const
data
=
await
userApi
.
login
(
user
)
console
.
log
(
data
)
console
.
log
(
data
)
handleLogin
(
data
.
id
)
setSuccess
(
true
)
setSuccess
(
true
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'
error in login
'
,
error
)
console
.
log
(
'
error in login
'
,
error
)
...
...
client/src/context/auth.js
0 → 100644
View file @
4a23dcaa
import
axios
from
'
axios
'
export
function
handleLogin
(
userId
)
{
localStorage
.
setItem
(
"
user
"
,
userId
)
}
export
async
function
handleLogout
()
{
alert
(
"
로그아웃되었습니다.
"
)
localStorage
.
removeItem
(
'
loginStatus
'
)
await
axios
.
get
(
'
/api/auth/logout
'
)
window
.
location
.
href
=
'
/
'
}
export
function
isAuthenticated
()
{
const
userId
=
localStorage
.
getItem
(
'
loginStatus
'
)
if
(
userId
)
{
return
userId
}
else
{
return
false
}
}
controllers/user.controller.js
View file @
4a23dcaa
...
@@ -79,8 +79,14 @@ const signup = async (req, res) => {
...
@@ -79,8 +79,14 @@ const signup = async (req, res) => {
}
}
}
}
const
logout
=
(
req
,
res
)
=>
{
res
.
clearCookie
(
'
token
'
)
res
.
send
(
'
Logout Successful
'
)
}
export
default
{
export
default
{
user
,
user
,
login
,
login
,
signup
,
signup
,
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