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
245ddecd
Commit
245ddecd
authored
Jul 27, 2021
by
우지원
Browse files
Merge remote-tracking branch 'origin/seoyeon2' into jiweon827
parents
4a23dcaa
3aa0a668
Changes
5
Show whitespace changes
Inline
Side-by-side
client/src/apis/user.api.js
View file @
245ddecd
import
axios
from
"
axios
"
;
const
getUser
=
async
(
payload
)
=>
{
const
{
data
}
=
await
axios
.
ge
t
(
"
/api/
u
ser
"
,
payload
);
const
{
data
}
=
await
axios
.
pos
t
(
"
/api/
getU
ser
"
,
payload
);
return
data
;
};
...
...
client/src/components/Home/HomeProfile.js
View file @
245ddecd
...
...
@@ -2,8 +2,10 @@ import { Link } from "react-router-dom";
import
{
useState
,
useEffect
}
from
"
react
"
;
import
userApi
from
"
../../apis/user.api
"
;
const
userprofile
=
localStorage
.
getItem
(
"
user
"
);
console
.
log
(
userprofile
)
const
INIT_USER
=
{
id
:
''
,
id
:
userprofile
,
name
:
''
,
img
:
''
,
}
...
...
@@ -11,14 +13,13 @@ const INIT_USER = {
const
HomeProfile
=
()
=>
{
const
[
user
,
setUser
]
=
useState
(
INIT_USER
)
const
id
=
localStorage
.
getItem
(
'
user
'
);
async
function
getUser
(
id
)
{
async
function
getSetUser
(
userID
)
{
try
{
// `/users/${userId}`랑 userId랑 같은지 확인
const
User
=
await
userApi
.
getUser
(
id
)
console
.
log
(
User
)
setUser
(
User
.
data
)
console
.
log
(
'
userID
'
,
userID
)
const
data
=
await
userApi
.
getUser
({
id
:
userID
})
console
.
log
(
data
)
setUser
(
data
)
console
.
log
(
user
)
}
catch
(
error
)
{
// catchErrors(error, setError)
...
...
@@ -26,11 +27,12 @@ const HomeProfile = () => {
}
useEffect
(()
=>
{
getUser
(
id
)
},
[
id
])
console
.
log
(
'
예에에에에ㅔ에에
'
)
getSetUser
(
userprofile
)
},
[
userprofile
])
return
(
<
Link
to
=
{
`/profile/
${
id
}
`
}
className
=
"
text-decoration-none text-dark
"
>
<
Link
to
=
{
`/profile/
${
user
}
`
}
className
=
"
text-decoration-none text-dark
"
>
<
form
className
=
"
flex-column align-items-center justify-content-center m-2
"
>
<
div
className
=
"
d-flex justify-content-center
"
>
<
img
...
...
client/src/context/auth.js
View file @
245ddecd
...
...
@@ -6,7 +6,7 @@ export function handleLogin(userId) {
export
async
function
handleLogout
()
{
alert
(
"
로그아웃되었습니다.
"
)
localStorage
.
removeItem
(
'
loginStatus
'
)
localStorage
.
removeItem
(
"
user
"
)
await
axios
.
get
(
'
/api/auth/logout
'
)
window
.
location
.
href
=
'
/
'
}
...
...
controllers/user.controller.js
View file @
245ddecd
...
...
@@ -4,9 +4,12 @@ import config from '../config/app.config.js'
import
isLength
from
'
validator/lib/isLength.js
'
import
bcrypt
from
"
bcryptjs
"
;
const
user
=
async
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
)
const
user
=
await
User
.
findAll
({
where
:
{
id
:
req
.
body
}
});
const
getUser
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
유저가져왔다아아아ㅏㅇ:
'
,
req
.
body
)
console
.
log
(
'
id:
'
,
req
.
body
.
id
)
const
id
=
req
.
body
.
id
const
user
=
await
User
.
findOne
({
where
:
{
id
:
id
}
});
console
.
log
(
'
user:
'
,
user
)
req
.
json
(
user
)
};
...
...
@@ -85,7 +88,7 @@ const logout = (req, res) => {
}
export
default
{
u
ser
,
getU
ser
,
login
,
signup
,
logout
,
...
...
routes/user.route.js
View file @
245ddecd
...
...
@@ -3,7 +3,7 @@ import userCtrl from "../controllers/user.controller.js";
const
router
=
express
.
Router
();
router
.
route
(
"
/getUser
"
).
ge
t
(
userCtrl
.
u
ser
);
router
.
route
(
"
/getUser
"
).
pos
t
(
userCtrl
.
getU
ser
);
router
.
route
(
"
/login
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/signup
"
).
post
(
userCtrl
.
signup
);
...
...
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