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
a1edd574
Commit
a1edd574
authored
Jul 28, 2021
by
이재연
Browse files
오잉
parent
b5bf87d3
Changes
20
Hide whitespace changes
Inline
Side-by-side
app.js
View file @
a1edd574
...
...
@@ -13,7 +13,7 @@ const server = http.createServer(app);
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
app
.
use
(
cookieParser
());
app
.
use
(
'
/uploads
'
,
express
.
static
(
'
uploads
'
))
app
.
use
(
"
/api
"
,
mainRouter
);
let
receiverPCs
=
{};
...
...
client/src/apis/user.api.js
View file @
a1edd574
...
...
@@ -15,11 +15,16 @@ const signup = async (payload) => {
return
data
;
};
const
profileimg
=
async
(
formData
)
=>
{
const
{
data
}
=
await
axios
.
put
(
"
/api/
profileimg
"
,
formData
);
const
updateinfo
=
async
(
payload
)
=>
{
const
{
data
}
=
await
axios
.
put
(
"
/api/
updateinfo
"
,
payload
);
return
data
;
}
};
const
profileimg
=
async
(
formData
)
=>
{
const
{
data
}
=
await
axios
.
put
(
"
/api/profileimg
"
,
formData
);
return
data
;
};
const
userApi
=
{
login
,
signup
,
profileimg
};
const
userApi
=
{
login
,
signup
,
getUser
,
profileimg
,
updateinfo
};
export
default
userApi
;
client/src/components/Home/HomeProfile.js
View file @
a1edd574
...
...
@@ -32,17 +32,17 @@ const HomeProfile = () => {
},
[
userprofile
])
return
(
<
Link
to
=
{
`/profile/
${
user
}
`
}
className
=
"
text-decoration-none text-dark
"
>
<
Link
to
=
{
`/profile/
${
user
.
id
}
`
}
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
//
src="cherry.jpg"
src
=
"
cherry.jpg
"
className
=
"
rounded-circle
"
style
=
{{
width
:
"
157px
"
,
height
:
"
157px
"
,
}}
value
=
{
user
.
img
}
//
value={user.img}
/
>
<
/div
>
<
h1
className
=
"
d-flex justify-content-center
"
>
{
user
.
name
}
<
/h1
>
...
...
client/src/components/Profile/Info.js
View file @
a1edd574
import
userApi
from
"
../../apis/user.api
"
;
import
{
useEffect
,
useState
}
from
"
react
"
;
// const INIT_ACCOUNT = {
// name: "",
// id:"",
// }
const
userprofile
=
localStorage
.
getItem
(
"
user
"
);
const
INIT_PROFILE
=
{
name
:
""
,
email
:
"
a
"
,
id
:
""
,
phone
:
""
,
};
const
Info
=
()
=>
{
const
[
profile
,
setProfile
]
=
useState
(
INIT_PROFILE
);
async
function
getProfile
(
userID
)
{
try
{
const
data
=
await
userApi
.
getUser
({
id
:
userID
});
setProfile
(
data
);
console
.
log
(
data
)
}
catch
(
error
)
{}
}
useEffect
(()
=>
{
getProfile
(
userprofile
);
},
[
userprofile
]);
const
Info
=
()
=>
{
return
(
<
div
className
=
"
container
"
style
=
{{
background
:
"
#FCF4FF
"
}}
>
<
div
className
=
"
row justify-content-center my-4
"
style
=
{{
fontSize
:
"
25px
"
,
fontWeight
:
"
bold
"
}}
>
CHERRY
#
0805
{
profile
.
email
}
#
{
profile
.
id
}
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-3
"
><
/div
>
...
...
@@ -22,14 +39,24 @@ const Info = () => {
<
h2
className
=
"
mb-3
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
이름
<
/h2
>
<
h2
className
=
"
mb-4 mt-2
"
style
=
{{
fontSize
:
"
25px
"
,
fontWeight
:
"
bold
"
}}
>
김채린
<
/h2
>
<
h2
className
=
"
mb-4 mt-2
"
style
=
{{
fontSize
:
"
25px
"
,
fontWeight
:
"
bold
"
}}
>
{
profile
.
name
}
<
/h2
>
<
h2
className
=
"
mb-3 mt-2
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
전화번호
<
/h2
>
<
h2
className
=
"
mb-3 mt-2
"
style
=
{{
fontSize
:
"
25px
"
,
fontWeight
:
"
bold
"
}}
>
010
-
8628
-
8984
<
/h2
>
<
h2
className
=
"
mb-3 mt-2
"
style
=
{{
fontSize
:
"
25px
"
,
fontWeight
:
"
bold
"
}}
>
{
profile
.
phone
}
<
/h2
>
<
/div
>
<
div
className
=
"
col
"
><
/div
>
<
/div
>
...
...
client/src/components/Profile/InfoUpdate.js
View file @
a1edd574
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
,
useParams
}
from
"
react-router-dom
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
userApi
from
"
../../apis/user.api
"
;
const
userprofile
=
localStorage
.
getItem
(
"
user
"
);
console
.
log
(
userprofile
);
const
INIT_PROFILE
=
{
id
:
""
,
avatarUrl
:
""
,
id
:
userprofile
,
name
:
""
,
email
:
""
,
phone
:
""
,
img
:
""
,
};
const
InfoUpdate
=
()
=>
{
const
{
id
}
=
useParams
();
const
[
profile
,
setProfile
]
=
useState
(
INIT_PROFILE
);
// useEffect(()=>{
// setProfile()
// },[profile])
async
function
getProfile
(
userID
)
{
try
{
const
data
=
await
userApi
.
getUser
({
id
:
userID
});
setProfile
(
data
);
console
.
log
(
data
);
}
catch
(
error
)
{}
}
useEffect
(()
=>
{
getProfile
(
userprofile
);
},
[]);
const
handleChange
=
async
(
event
)
=>
{
const
{
name
,
files
}
=
event
.
target
;
let
formData
=
new
FormData
;
formData
.
append
(
"
avatarUrl
"
,
files
[
0
]);
const
res
=
await
userApi
.
profileimg
(
formData
);
console
.
log
(
res
.
img
)
console
.
log
(
res
.
id
)
setProfile
({
...
profile
,
avatarUrl
:
res
.
img
})
setProfile
({
...
profile
,
id
:
res
.
id
})
};
const
{
files
}
=
event
.
target
;
let
formData
=
new
FormData
();
formData
.
append
(
"
img
"
,
files
[
0
]);
formData
.
append
(
"
id
"
,
userprofile
);
try
{
const
res
=
await
userApi
.
profileimg
(
formData
);
console
.
log
(
res
);
if
(
files
){
setProfile
({...
profile
,
img
:
res
})
}
else
{
setProfile
()
}
}
catch
(
error
)
{}
};
const
{
id
,
avatarUrl
}
=
profile
;
const
changeinfo
=
async
(
event
)
=>
{
console
.
log
(
profile
);
const
res
=
await
userApi
.
updateinfo
(
profile
)
};
const
updateinfo
=
(
event
)
=>
{
const
{
name
,
value
}
=
event
.
target
;
setProfile
({
...
profile
,
[
name
]:
value
});
console
.
log
(
profile
);
};
const
{
email
,
phone
,
name
}
=
profile
return
(
<
div
className
=
"
container
"
style
=
{{
background
:
"
#FCF4FF
"
}}
>
<
div
className
=
"
row
"
>
...
...
@@ -39,7 +66,7 @@ const InfoUpdate = () => {
>
프로필
정보
<
/label
>
<
Link
to
=
{
`/profile/
${
profile
.
id
}
`
}
>
<
Link
to
=
{
`/profile/
${
id
}
`
}
>
<
button
type
=
"
button
"
className
=
"
btn btn-outline-white
"
...
...
@@ -52,6 +79,20 @@ const InfoUpdate = () => {
돌아가기
<
/button
>
<
/Link
>
<
Link
to
=
{
`/profile/
${
id
}
`
}
>
<
button
onClick
=
{
changeinfo
}
type
=
"
button
"
className
=
"
btn btn-outline-white mx-2
"
style
=
{{
background
:
"
#d4cafb
"
,
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
,
}}
>
저장
<
/button
>
<
/Link
>
<
/div
>
<
/div
>
...
...
@@ -63,7 +104,7 @@ const InfoUpdate = () => {
style
=
{{
position
:
"
relative
"
}}
>
<
img
src
=
'
/user.png
'
src
=
{
`/uploads/
${
profile
.
img
}
`
}
id
=
"
imgfile
"
className
=
"
rounded-circle mt-2
"
style
=
{{
height
:
"
320px
"
,
width
:
"
320px
"
}}
...
...
@@ -72,30 +113,33 @@ const InfoUpdate = () => {
className
=
"
d-flex justify-content-end
"
style
=
{{
position
:
"
absolute
"
,
left
:
"
295px
"
,
top
:
"
30px
"
}}
>
<
label
for
=
"
inputfile
"
>
<
img
className
=
"
rounded-circle
"
src
=
"
/infoimg.jpg
"
style
=
{{
width
:
"
50px
"
,
height
:
"
50px
"
,
backgroundColor
:
"
white
"
,
}}
/
>
<
/label
>
<
input
onChange
=
{
handleChange
}
name
=
"
avatarUrl
"
type
=
"
file
"
accept
=
"
image/*
"
id
=
"
inputfile
"
style
=
{{
display
:
"
none
"
}}
<
label
htmlFor
=
"
inputfile
"
>
<
img
className
=
"
rounded-circle
"
src
=
"
/infoimg.jpg
"
style
=
{{
width
:
"
50px
"
,
height
:
"
50px
"
,
backgroundColor
:
"
white
"
,
}}
/
>
<
/label
>
<
input
onChange
=
{
handleChange
}
name
=
"
avatarUrl
"
type
=
"
file
"
accept
=
"
image/*
"
id
=
"
inputfile
"
style
=
{{
display
:
"
none
"
}}
/
>
<
/div
>
<
/div
>
<
div
className
=
"
col d-flex justify-content-center
"
>
<
input
onChange
=
{
updateinfo
}
name
=
"
email
"
value
=
{
profile
.
email
}
type
=
"
text
"
className
=
"
form-control my-4
"
placeholder
=
"
사용자명 입력
"
...
...
@@ -114,82 +158,63 @@ const InfoUpdate = () => {
className
=
"
justify-content-center ms-2 my-4
"
style
=
{{
fontSize
:
"
25px
"
,
fontWeight
:
"
bold
"
}}
>
#
{
profile
.
id
}
#
{
user
profile
}
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-3
"
><
/div
>
<
div
className
=
"
col-6 my-2
"
>
<
h2
className
=
"
mb-3
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
이름
<
/h2
>
<
input
onChange
=
{
updateinfo
}
name
=
"
name
"
value
=
{
profile
.
name
}
type
=
"
text
"
className
=
"
form-control my-3
"
placeholder
=
"
이름 입력
"
style
=
{{
background
:
"
#fcf4ff
"
,
borderTop
:
"
0
"
,
borderRight
:
"
0
"
,
borderLeft
:
"
0
"
,
borderBottom
:
"
1
"
,
borderColor
:
"
#d4cafb
"
,
height
:
"
38px
"
,
width
:
"
180px
"
,
}}
/
>
<
div
className
=
"
d-flex justify-content-center
"
>
<
label
class
=
"
form-label me-3
"
style
=
{{
outline
:
"
none
"
,
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
,
}}
>
현재
비밀번호
<
/label
>
<
input
onChange
=
{
handleChange
}
type
=
"
text
"
class
=
"
form-control
"
style
=
{{
height
:
"
38px
"
,
width
:
"
200px
"
}}
/
>
<
button
type
=
"
button
"
className
=
"
btn btn-outline-white ms-2
"
style
=
{{
background
:
"
#d4cafb
"
,
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
,
}}
>
수정하기
<
/button
>
<
/div
>
<
div
class
=
"
col-6
"
>
<
div
class
=
"
input-group mx-2 my-3
"
>
<
div
>
<
label
class
=
"
form-label
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
새
비밀번호
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
/>
<
/div
>
<
div
>
<
label
className
=
"
form-label
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
새
비밀번호
확인
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
/>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
col-6
"
>
<
div
className
=
"
input-group my-3
"
>
<
div
>
<
label
className
=
"
form-label
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
새
전화번호
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
/>
<
/div
>
<
div
>
<
label
className
=
"
form-label
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
새
전화번호
확인
<
/label
>
<
input
type
=
"
text
"
className
=
"
form-control
"
/>
<
/div
>
<
h2
className
=
"
mb-3 mt-2
"
style
=
{{
fontSize
:
"
13px
"
,
fontWeight
:
"
bold
"
}}
>
전화번호
<
/h2
>
<
input
onChange
=
{
updateinfo
}
name
=
"
phone
"
value
=
{
profile
.
phone
}
type
=
"
text
"
className
=
"
form-control my-3
"
placeholder
=
"
전화번호 입력
"
style
=
{{
background
:
"
#fcf4ff
"
,
borderTop
:
"
0
"
,
borderRight
:
"
0
"
,
borderLeft
:
"
0
"
,
borderBottom
:
"
1
"
,
borderColor
:
"
#d4cafb
"
,
height
:
"
38px
"
,
width
:
"
180px
"
,
}}
/
>
<
/div
>
<
div
className
=
"
col
"
><
/div
>
<
/div
>
<
/div
>
<
/div
>
...
...
client/src/components/Profile/Profile.js
View file @
a1edd574
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
,
useParams
}
from
"
react-router-dom
"
;
import
{
useState
,
useEffect
}
from
"
react
"
;
import
userApi
from
"
../../apis/user.api
"
;
const
userprofile
=
localStorage
.
getItem
(
"
user
"
);
const
INIT_PROFILE
=
{
img
:
""
,
};
const
Profile
=
()
=>
{
const
id
=
1
;
const
[
profile
,
setProfile
]
=
useState
(
INIT_PROFILE
);
async
function
getProfile
(
userID
)
{
try
{
const
data
=
await
userApi
.
getUser
({
id
:
userID
});
console
.
log
(
data
.
img
)
setProfile
(
data
.
img
)
}
catch
(
error
)
{}
}
useEffect
(()
=>
{
getProfile
(
userprofile
);
},
[
userprofile
]);
const
{
id
}
=
useParams
();
console
.
log
(
id
);
return
(
<
div
className
=
"
container
"
style
=
{{
background
:
"
#FCF4FF
"
}}
>
<>
...
...
@@ -31,7 +57,7 @@ const Profile = () => {
<
div
className
=
"
col
"
>
<
div
className
=
"
d-flex justify-content-center
"
>
<
img
src
=
"
/cherry.jpg
"
src
=
{
`/uploads/
${
profile
}
`
}
className
=
"
rounded-circle mt-2
"
style
=
{{
height
:
"
320px
"
,
width
:
"
320px
"
}}
/
>
...
...
client/yarn.lock
View file @
a1edd574
...
...
@@ -105,9 +105,9 @@
browserslist "^4.14.5"
semver "^5.5.0"
"@babel/helper-create-class-features-plugin@^7.12.1", "@babel/helper-create-class-features-plugin@^7.12.13", "@babel/helper-create-class-features-plugin@^7.12.17":
"@babel/helper-create-class
Name
-features-plugin@^7.12.1", "@babel/helper-create-class
Name
-features-plugin@^7.12.13", "@babel/helper-create-class
Name
-features-plugin@^7.12.17":
version "7.12.17"
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.17.tgz#704b69c8a78d03fb1c5fcc2e7b593f8a65628944"
resolved "https://registry.yarnpkg.com/@babel/helper-create-class
Name
-features-plugin/-/helper-create-class
Name
-features-plugin-7.12.17.tgz#704b69c8a78d03fb1c5fcc2e7b593f8a65628944"
integrity sha512-I/nurmTxIxHV0M+rIpfQBF1oN342+yvl2kwZUrQuOClMamHF1w5tknfZubgNOLRoA73SzBFAdFcpb4M9HwOeWQ==
dependencies:
"@babel/helper-function-name" "^7.12.13"
...
...
@@ -287,20 +287,20 @@
"@babel/helper-remap-async-to-generator" "^7.12.13"
"@babel/plugin-syntax-async-generators" "^7.8.0"
"@babel/plugin-proposal-class-properties@7.12.1":
"@babel/plugin-proposal-class
Name
-properties@7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class
Name
-properties/-/plugin-proposal-class
Name
-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de"
integrity sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.1"
"@babel/helper-create-class
Name
-features-plugin" "^7.12.1"
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-proposal-class-properties@^7.12.1", "@babel/plugin-proposal-class-properties@^7.12.13":
"@babel/plugin-proposal-class
Name
-properties@^7.12.1", "@babel/plugin-proposal-class
Name
-properties@^7.12.13":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.13.tgz#3d2ce350367058033c93c098e348161d6dc0d8c8"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class
Name
-properties/-/plugin-proposal-class
Name
-properties-7.12.13.tgz#3d2ce350367058033c93c098e348161d6dc0d8c8"
integrity sha512-8SCJ0Ddrpwv4T7Gwb33EmW1V9PY5lggTO+A8WjyIwxrSHDUyBw4MtF96ifn1n8H806YlxbVCoKXbbmzD6RD+cA==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.13"
"@babel/helper-create-class
Name
-features-plugin" "^7.12.13"
"@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-proposal-decorators@7.12.1":
...
...
@@ -308,7 +308,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.12.1.tgz#59271439fed4145456c41067450543aee332d15f"
integrity sha512-knNIuusychgYN8fGJHONL0RbFxLGawhXOJNLBk75TniTsZZeA+wdkDuv6wp4lGwzQEKjZi6/WYtnb3udNPmQmQ==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.1"
"@babel/helper-create-class
Name
-features-plugin" "^7.12.1"
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-decorators" "^7.12.1"
...
...
@@ -416,7 +416,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.12.13.tgz#ea78a12554d784ecf7fc55950b752d469d9c4a71"
integrity sha512-sV0V57uUwpauixvR7s2o75LmwJI6JECwm5oPUY5beZB1nBl2i37hc7CJGqB5G+58fur5Y6ugvl3LRONk5x34rg==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.13"
"@babel/helper-create-class
Name
-features-plugin" "^7.12.13"
"@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-proposal-unicode-property-regex@^7.12.1", "@babel/plugin-proposal-unicode-property-regex@^7.12.13", "@babel/plugin-proposal-unicode-property-regex@^7.4.4":
...
...
@@ -441,9 +441,9 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-class-properties@^7.12.1", "@babel/plugin-syntax-class-properties@^7.12.13", "@babel/plugin-syntax-class-properties@^7.8.3":
"@babel/plugin-syntax-class
Name
-properties@^7.12.1", "@babel/plugin-syntax-class
Name
-properties@^7.12.13", "@babel/plugin-syntax-class
Name
-properties@^7.8.3":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class
Name
-properties/-/plugin-syntax-class
Name
-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10"
integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==
dependencies:
"@babel/helper-plugin-utils" "^7.12.13"
...
...
@@ -583,9 +583,9 @@
dependencies:
"@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-transform-classes@^7.12.1", "@babel/plugin-transform-classes@^7.12.13":
"@babel/plugin-transform-class
Name
es@^7.12.1", "@babel/plugin-transform-class
Name
es@^7.12.13":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.12.13.tgz#9728edc1838b5d62fc93ad830bd523b1fcb0e1f6"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class
Name
es/-/plugin-transform-class
Name
es-7.12.13.tgz#9728edc1838b5d62fc93ad830bd523b1fcb0e1f6"
integrity sha512-cqZlMlhCC1rVnxE5ZGMtIb896ijL90xppMiuWXcwcOAuFczynpd3KYemb91XFFPi3wJSe/OcrX9lXoowatkkxA==
dependencies:
"@babel/helper-annotate-as-pure" "^7.12.13"
...
...
@@ -870,7 +870,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.17.tgz#4aa6a5041888dd2e5d316ec39212b0cf855211bb"
integrity sha512-1bIYwnhRoetxkFonuZRtDZPFEjl1l5r+3ITkxLC3mlMaFja+GQFo94b/WHEPjqWLU9Bc+W4oFZbvCGe9eYMu1g==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.17"
"@babel/helper-create-class
Name
-features-plugin" "^7.12.17"
"@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-syntax-typescript" "^7.12.13"
...
...
@@ -900,7 +900,7 @@
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/helper-validator-option" "^7.12.1"
"@babel/plugin-proposal-async-generator-functions" "^7.12.1"
"@babel/plugin-proposal-class-properties" "^7.12.1"
"@babel/plugin-proposal-class
Name
-properties" "^7.12.1"
"@babel/plugin-proposal-dynamic-import" "^7.12.1"
"@babel/plugin-proposal-export-namespace-from" "^7.12.1"
"@babel/plugin-proposal-json-strings" "^7.12.1"
...
...
@@ -913,7 +913,7 @@
"@babel/plugin-proposal-private-methods" "^7.12.1"
"@babel/plugin-proposal-unicode-property-regex" "^7.12.1"
"@babel/plugin-syntax-async-generators" "^7.8.0"
"@babel/plugin-syntax-class-properties" "^7.12.1"
"@babel/plugin-syntax-class
Name
-properties" "^7.12.1"
"@babel/plugin-syntax-dynamic-import" "^7.8.0"
"@babel/plugin-syntax-export-namespace-from" "^7.8.3"
"@babel/plugin-syntax-json-strings" "^7.8.0"
...
...
@@ -928,7 +928,7 @@
"@babel/plugin-transform-async-to-generator" "^7.12.1"
"@babel/plugin-transform-block-scoped-functions" "^7.12.1"
"@babel/plugin-transform-block-scoping" "^7.12.1"
"@babel/plugin-transform-classes" "^7.12.1"
"@babel/plugin-transform-class
Name
es" "^7.12.1"
"@babel/plugin-transform-computed-properties" "^7.12.1"
"@babel/plugin-transform-destructuring" "^7.12.1"
"@babel/plugin-transform-dotall-regex" "^7.12.1"
...
...
@@ -972,7 +972,7 @@
"@babel/helper-plugin-utils" "^7.12.13"
"@babel/helper-validator-option" "^7.12.17"
"@babel/plugin-proposal-async-generator-functions" "^7.12.13"
"@babel/plugin-proposal-class-properties" "^7.12.13"
"@babel/plugin-proposal-class
Name
-properties" "^7.12.13"
"@babel/plugin-proposal-dynamic-import" "^7.12.17"
"@babel/plugin-proposal-export-namespace-from" "^7.12.13"
"@babel/plugin-proposal-json-strings" "^7.12.13"
...
...
@@ -985,7 +985,7 @@
"@babel/plugin-proposal-private-methods" "^7.12.13"
"@babel/plugin-proposal-unicode-property-regex" "^7.12.13"
"@babel/plugin-syntax-async-generators" "^7.8.0"
"@babel/plugin-syntax-class-properties" "^7.12.13"
"@babel/plugin-syntax-class
Name
-properties" "^7.12.13"
"@babel/plugin-syntax-dynamic-import" "^7.8.0"
"@babel/plugin-syntax-export-namespace-from" "^7.8.3"
"@babel/plugin-syntax-json-strings" "^7.8.0"
...
...
@@ -1000,7 +1000,7 @@
"@babel/plugin-transform-async-to-generator" "^7.12.13"
"@babel/plugin-transform-block-scoped-functions" "^7.12.13"
"@babel/plugin-transform-block-scoping" "^7.12.13"
"@babel/plugin-transform-classes" "^7.12.13"
"@babel/plugin-transform-class
Name
es" "^7.12.13"
"@babel/plugin-transform-computed-properties" "^7.12.13"
"@babel/plugin-transform-destructuring" "^7.12.13"
"@babel/plugin-transform-dotall-regex" "^7.12.13"
...
...
@@ -2610,7 +2610,7 @@ babel-preset-current-node-syntax@^1.0.0:
dependencies:
"@babel/plugin-syntax-async-generators" "^7.8.4"
"@babel/plugin-syntax-bigint" "^7.8.3"
"@babel/plugin-syntax-class-properties" "^7.8.3"
"@babel/plugin-syntax-class
Name
-properties" "^7.8.3"
"@babel/plugin-syntax-import-meta" "^7.8.3"
"@babel/plugin-syntax-json-strings" "^7.8.3"
"@babel/plugin-syntax-logical-assignment-operators" "^7.8.3"
...
...
@@ -2635,7 +2635,7 @@ babel-preset-react-app@^10.0.0:
integrity sha512-itL2z8v16khpuKutx5IH8UdCdSTuzrOhRFTEdIhveZ2i1iBKDrVE0ATa4sFVy+02GLucZNVBWtoarXBy0Msdpg==
dependencies:
"@babel/core" "7.12.3"
"@babel/plugin-proposal-class-properties" "7.12.1"
"@babel/plugin-proposal-class
Name
-properties" "7.12.1"
"@babel/plugin-proposal-decorators" "7.12.1"
"@babel/plugin-proposal-nullish-coalescing-operator" "7.12.1"
"@babel/plugin-proposal-numeric-separator" "7.12.1"
...
...
@@ -2679,7 +2679,7 @@ base@^0.11.1:
integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==
dependencies:
cache-base "^1.0.1"
class-utils "^0.3.5"
class
Name
-utils "^0.3.5"
component-emitter "^1.2.1"
define-property "^1.0.0"
isobject "^3.0.1"
...
...
@@ -3205,9 +3205,9 @@ cjs-module-lexer@^0.6.0:
resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz#4186fcca0eae175970aee870b9fe2d6cf8d5655f"
integrity sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw==
class-utils@^0.3.5:
class
Name
-utils@^0.3.5:
version "0.3.6"
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
resolved "https://registry.yarnpkg.com/class
Name
-utils/-/class
Name
-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==
dependencies:
arr-union "^3.1.0"
...
...
@@ -4716,7 +4716,7 @@ expand-brackets@^2.1.4:
debug "^2.3.3"
define-property "^0.2.5"
extend-shallow "^2.0.1"
posix-character-classes "^0.1.0"
posix-character-class
Name
es "^0.1.0"
regex-not "^1.0.0"
snapdragon "^0.8.1"
to-regex "^3.0.1"
...
...
@@ -7991,9 +7991,9 @@ portfinder@^1.0.26:
debug "^3.1.1"
mkdirp "^0.5.5"
posix-character-classes@^0.1.0:
posix-character-class
Name
es@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
resolved "https://registry.yarnpkg.com/posix-character-class
Name
es/-/posix-character-class
Name
es-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
postcss-attribute-case-insensitive@^4.0.1:
...
...
@@ -8104,9 +8104,9 @@ postcss-custom-selectors@^5.1.2:
postcss "^7.0.2"
postcss-selector-parser "^5.0.0-rc.3"
postcss-dir-pseudo-class@^5.0.0:
postcss-dir-pseudo-class
Name
@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-5.0.0.tgz#6e3a4177d0edb3abcc85fdb6fbb1c26dabaeaba2"
resolved "https://registry.yarnpkg.com/postcss-dir-pseudo-class
Name
/-/postcss-dir-pseudo-class
Name
-5.0.0.tgz#6e3a4177d0edb3abcc85fdb6fbb1c26dabaeaba2"
integrity sha512-3pm4oq8HYWMZePJY+5ANriPs3P07q+LW6FAdTlkFH2XqDdP4HeeJYMOzn0HYLhRSjBO3fhiqSwwU9xEULSrPgw==
dependencies:
postcss "^7.0.2"
...
...
@@ -8495,7 +8495,7 @@ postcss-preset-env@6.7.0:
postcss-custom-media "^7.0.8"
postcss-custom-properties "^8.0.11"
postcss-custom-selectors "^5.1.2"
postcss-dir-pseudo-class "^5.0.0"
postcss-dir-pseudo-class
Name
"^5.0.0"
postcss-double-position-gradients "^1.0.0"
postcss-env-function "^2.0.2"
postcss-focus-visible "^4.0.0"
...
...
@@ -8511,14 +8511,14 @@ postcss-preset-env@6.7.0:
postcss-overflow-shorthand "^2.0.0"
postcss-page-break "^2.0.0"
postcss-place "^4.0.1"
postcss-pseudo-class-any-link "^6.0.0"
postcss-pseudo-class
Name
-any-link "^6.0.0"
postcss-replace-overflow-wrap "^3.0.0"
postcss-selector-matches "^4.0.0"
postcss-selector-not "^4.0.0"
postcss-pseudo-class-any-link@^6.0.0:
postcss-pseudo-class
Name
-any-link@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-6.0.0.tgz#2ed3eed393b3702879dec4a87032b210daeb04d1"
resolved "https://registry.yarnpkg.com/postcss-pseudo-class
Name
-any-link/-/postcss-pseudo-class
Name
-any-link-6.0.0.tgz#2ed3eed393b3702879dec4a87032b210daeb04d1"
integrity sha512-lgXW9sYJdLqtmw23otOzrtbDXofUdfYzNm4PIpNE322/swES3VU9XlXHeJS46zT2onFO7V1QFdD4Q9LiZj8mew==
dependencies:
postcss "^7.0.2"
...
...
controllers/user.controller.js
View file @
a1edd574
import
{
User
}
from
'
../models/index.js
'
import
jwt
from
'
jsonwebtoken
'
import
config
from
'
../config/app.config.js
'
import
isLength
from
'
validator/lib/isLength.js
'
import
bcrypt
from
"
bcryptjs
"
;
import
{
User
}
from
"
../models/index.js
"
;
import
jwt
from
"
jsonwebtoken
"
;
import
config
from
"
../config/app.config.js
"
;
import
isLength
from
"
validator/lib/isLength.js
"
;
const
multer
=
require
(
'
multer
'
);
const
uploadimg
=
multer
({
dest
:
'
uploads/
'
});
const
multer
=
require
(
"
multer
"
);
const
uploadimg
=
multer
({
dest
:
"
uploads/
"
});
const
imgUpload
=
uploadimg
.
fields
([
{
name
:
'
avatarUrl
'
,
maxCount
:
1
}
])
const
imgUpload
=
uploadimg
.
fields
([{
name
:
"
img
"
,
maxCount
:
1
}]);
const
update
=
async
(
req
,
res
)
=>
{
try
{
const
avatar
=
req
.
files
[
'
avatarUrl
'
][
0
]
const
avatarUrl
=
avatar
.
filename
console
.
log
(
avatarUrl
)
await
User
.
update
({
'
img
'
:
avatarUrl
},{
where
:{
id
:
'
9999
'
}}
)
const
userId
=
await
User
.
findOne
({
where
:
{
id
:
'
9999
'
}})
return
res
.
json
(
userId
)
console
.
log
(
"
id:
"
,
req
.
body
.
id
);
const
id
=
req
.
body
.
id
;
const
avatar
=
req
.
files
[
"
img
"
][
0
];
const
img
=
avatar
.
filename
;
console
.
log
(
img
);
await
User
.
update
({
img
:
img
},
{
where
:
{
id
:
id
}
});
res
.
json
(
img
);
}
catch
(
error
)
{
console
.
log
(
error
);
res
.
status
(
500
).
send
(
'
이미지 업데이트 실패
'
)
console
.
log
(
error
);
res
.
status
(
500
).
send
(
"
이미지 업데이트 실패
"
);
}
}
}
;
const
getUser
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
유저가져왔다아아아ㅏㅇ:
'
,
req
.
body
)
console
.
log
(
'
id:
'
,
req
.
body
.
id
)
const
id
=
req
.
body
.
id
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
)
re
q
.
json
(
user
)
console
.
log
(
"
user:
"
,
user
)
;
re
s
.
json
(
user
)
;
};
const
updateinfo
=
async
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
const
{
id
,
name
,
email
,
phone
,
img
}
=
req
.
body
;
console
.
log
(
"
id:
"
,
id
);
const
A
=
{
name
:
name
,
email
:
email
,
phone
:
phone
,
img
:
img
,
};
await
User
.
update
(
A
,
{
where
:
{
id
:
id
}
});
const
user
=
await
User
.
findOne
({
where
:
{
id
:
id
}
});
console
.
log
(
'
user:
'
,
user
)
};
const
login
=
async
(
req
,
res
)
=>
{
try
{
console
.
log
(
'
login=
'
,
req
.
body
)
const
{
email
,
password
}
=
req
.
body
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
console
.
log
(
"
login=
"
,
req
.
body
)
;
const
{
email
,
password
}
=
req
.
body
;
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
;
if
(
!
user
)
{
return
res
.
status
(
422
).
send
(
`
${
email
}
사용자가 존재하지 않습니다.`
)
return
res
.
status
(
422
).
send
(
`
${
email
}
사용자가 존재하지 않습니다.`
)
;
}
else
{
const
passworMatch
=
await
user
.
comparePassword
(
password
)
const
passworMatch
=
await
user
.
comparePassword
(
password
)
;
if
(
passworMatch
)
{
const
token
=
jwt
.
sign
({
userID
:
user
.
id
},
config
.
jwtSecret
,
{
expiresIn
:
config
.
jwtExpires
,
})
})
;
res
.
cookie
(
config
.
cookieName
,
token
,
{
path
:
'
/
'
,
path
:
"
/
"
,
httpOnly
:
true
,
secure
:
true
,
})
res
.
json
(
user
)
})
;
res
.
json
(
user
)
;
}
else
{
res
.
status
(
401
).
send
(
'
비밀번호가 일치하지 않습니다.
'
)
res
.
status
(
401
).
send
(
"
비밀번호가 일치하지 않습니다.
"
);
}
}
}
catch
(
error
)
{
console
.
log
(
error
)
return
res
.
status
(
500
).
send
(
'
로그인 중 에러
'
)
console
.
log
(
error
)
;
return
res
.
status
(
500
).
send
(
"
로그인 중 에러
"
);
}
}
}
;
const
signup
=
async
(
req
,
res
)
=>
{
try
{
console
.
log
(
'
sign up=
'
,
req
.
body
)
const
{
name
,
email
,
password
,
gender
,
phone
}
=
req
.
body
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
console
.
log
(
'
id:
'
,
id
)
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
console
.
log
(
'
Id 중복확인:
'
,
Id
)
console
.
log
(
"
sign up=
"
,
req
.
body
)
;
const
{
name
,
email
,
password
,
gender
,
phone
}
=
req
.
body
;
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
;
console
.
log
(
"
id:
"
,
id
)
;
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
;
console
.
log
(
"
Id 중복확인:
"
,
Id
)
;
while
(
Id
)
{
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
;
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
;
}
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
;
if
(
user
)
return
res
.
status
(
422
).
send
(
`
${
email
}
이미 존재하는 사용자입니다.`
)
return
res
.
status
(
422
).
send
(
`
${
email
}
이미 존재하는 사용자입니다.`
)
;
if
(
!
isLength
(
name
,
{
min
:
3
,
max
:
10
}))
{
return
res
.
status
(
422
).
send
(
'
이름은 3-10자 사이입니다
'
)
return
res
.
status
(
422
).
send
(
"
이름은 3-10자 사이입니다
"
);
}
else
if
(
!
isLength
(
password
,
{
min
:
6
}))
{
return
res
.
status
(
422
).
send
(
'
비밀번호는 6자이상 입니다
'
)
return
res
.
status
(
422
).
send
(
"
비밀번호는 6자이상 입니다
"
);
}
else
if
(
!
isLength
(
email
,
{
min
:
3
,
max
:
10
}))
{
return
res
.
status
(
422
).
send
(
'
아이디는 3-10자 사이입니다
'
)
return
res
.
status
(
422
).
send
(
"
아이디는 3-10자 사이입니다
"
);
}
const
newUser
=
await
User
.
create
({
id
:
id
,
...
...
@@ -93,24 +105,26 @@ const signup = async (req, res) => {
password
:
password
,
gender
:
gender
,
phone
:
phone
,
}).
then
(
_
=>
console
.
log
(
'
회원가입 정보
'
,
id
,
name
,
email
,
password
,
gender
,
phone
)
,
)
}).
then
(
(
_
)
=>
console
.
log
(
"
회원가입 정보
"
,
id
,
name
,
email
,
password
,
gender
,
phone
)
)
;
}
catch
(
error
)
{
console
.
log
(
error
)
return
res
.
status
(
500
).
send
(
'
회원가입 중 에러
'
)
console
.
log
(
error
)
;
return
res
.
status
(
500
).
send
(
"
회원가입 중 에러
"
);
}
}
}
;
const
logout
=
(
req
,
res
)
=>
{
res
.
clearCookie
(
'
token
'
)
res
.
send
(
'
Logout Successful
'
)
}
res
.
clearCookie
(
"
token
"
);
res
.
send
(
"
Logout Successful
"
);
}
;
export
default
{
getUser
,
login
,
signup
,
logout
,
imgUpload
,
update
}
imgUpload
,
update
,
updateinfo
,
};
models/user.model.js
View file @
a1edd574
import
bcrypt
from
"
bcryptjs
"
;
import
{
DataTypes
}
from
"
sequelize
"
;
// import img from 'bora_it\client\public\user.png'
const
UserModel
=
(
sequelize
)
=>
{
const
User
=
sequelize
.
define
(
...
...
@@ -26,7 +27,7 @@ const UserModel = (sequelize) => {
},
img
:
{
type
:
DataTypes
.
STRING
,
defaultValue
:
"
/user.png
"
//
defaultValue:
img
},
roomNumber
:
{
type
:
DataTypes
.
ARRAY
(
DataTypes
.
STRING
),
...
...
routes/user.route.js
View file @
a1edd574
...
...
@@ -9,6 +9,8 @@ router.route("/signup").post(userCtrl.signup);
router
.
route
(
"
/profileimg
"
)
.
put
(
userCtrl
.
imgUpload
,
userCtrl
.
update
)
router
.
route
(
"
/updateinfo
"
)
.
put
(
userCtrl
.
updateinfo
)
router
.
route
(
"
/
"
).
post
(
userCtrl
.
signup
);
export
default
router
;
uploads/3f158c8340e16938031e6df696c088af
0 → 100644
View file @
a1edd574
File added
uploads/68fd60482788a9df0c358c9323aa9075
0 → 100644
View file @
a1edd574
File added
uploads/6cddde1b9caa62f789458ac66ae508d8
0 → 100644
View file @
a1edd574
File added
uploads/b2a145f26900e439df81d48af7762c07
0 → 100644
View file @
a1edd574
File added
uploads/b5536e4b4d4c1f4287e54ead790b0451
0 → 100644
View file @
a1edd574
File added
uploads/c958ad4c2bc1e709b76a050382676c38
0 → 100644
View file @
a1edd574
File added
uploads/ce1df3f429910ac0e9570d8bcf22cd1e
0 → 100644
View file @
a1edd574
File added
uploads/d9329d69444e01ce2a54538f772edf62
0 → 100644
View file @
a1edd574
File added
uploads/e920be94420873237d0232637fbdd54f
0 → 100644
View file @
a1edd574
File added
uploads/f7bb658b7409026561a90130a23e092e
0 → 100644
View file @
a1edd574
File added
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