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
shopping-mall
Commits
ea8ae1a0
Commit
ea8ae1a0
authored
Jan 04, 2021
by
이재연
Browse files
회원가입중..
parent
f3f88776
Changes
10
Show whitespace changes
Inline
Side-by-side
.env
View file @
ea8ae1a0
BROWSER=none
BROWSER=none
PORT=4000
PORT=4000
MONGO_URI=mongodb://localhost/
MONGO_URI=mongodb://localhost/shopping-mall
\ No newline at end of file
\ No newline at end of file
client/debug.log
0 → 100644
View file @
ea8ae1a0
[0102/195101.790:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
client/package.json
View file @
ea8ae1a0
...
@@ -38,5 +38,6 @@
...
@@ -38,5 +38,6 @@
"last 1 firefox version"
,
"last 1 firefox version"
,
"last 1 safari version"
"last 1 safari version"
]
]
}
},
"proxy"
:
"http://localhost:3001"
}
}
client/src/Pages/Login.js
View file @
ea8ae1a0
...
@@ -10,8 +10,7 @@ function Login(){
...
@@ -10,8 +10,7 @@ function Login(){
const
handleSubmit
=
(
e
)
=>
{
const
handleSubmit
=
(
e
)
=>
{
const
form
=
e
.
currentTarget
;
const
form
=
e
.
currentTarget
;
console
.
log
(
form
)
if
(
form
.
checkValidity
()
===
false
){
//checkValidity 는 입력 요소에 유효한 데이터가 포함되어 있는지 확인
if
(
form
.
checkValidity
()
===
false
){
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
stopPropagation
();
}
}
...
...
client/src/Pages/Signup.js
View file @
ea8ae1a0
...
@@ -2,79 +2,62 @@ import React, { useState, useEffect, useRef } from 'react';
...
@@ -2,79 +2,62 @@ import React, { useState, useEffect, useRef } from 'react';
import
{
Redirect
}
from
'
react-router-dom
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
Nav1
from
'
../Components/MainNav
'
;
import
Nav1
from
'
../Components/MainNav
'
;
import
Nav2
from
'
../Components/SubNav
'
;
import
Nav2
from
'
../Components/SubNav
'
;
import
{
Form
,
Col
,
Container
,
Button
,
Row
}
from
'
react-bootstrap
'
import
{
Form
,
Col
,
Container
,
Button
,
Row
,
Alert
}
from
'
react-bootstrap
'
import
FormCheckInput
from
'
react-bootstrap/esm/FormCheckInput
'
;
import
FormCheckInput
from
'
react-bootstrap/esm/FormCheckInput
'
;
import
DaumPostcode
from
"
react-daum-postcode
"
;
import
DaumPostcode
from
"
react-daum-postcode
"
;
const
INIT_USER
=
{
name
:
''
,
number
:
''
,
id
:
''
,
password
:
''
,
password2
:
''
,
tel
:
''
}
function
Signup
()
{
function
Signup
()
{
const
[
address
,
setAddress
]
=
useState
(
""
)
const
[
user
,
setUser
]
=
useState
(
true
)
//const [disabled, setDisabled] = useState(true)
const
handleComplete
=
(
data
)
=>
{
const
[
error
,
setError
]
=
useState
(
''
)
let
fullAddress
=
data
.
address
;
let
extraAddress
=
""
;
//useEffect(() => {
// const isUser = Object.values(user).every(el => Boolean(el))
console
.
log
(
data
)
// isUser ? setDisabled(false) : setDisabled(true)
//}, user)
if
(
data
.
addressType
===
"
R
"
)
{
if
(
data
.
bname
!==
""
)
{
function
handleChange
(
event
)
{
extraAddress
+=
data
.
bname
;
const
{
name
,
value
}
=
event
.
target
console
.
log
(
extraAddress
)
setUser
({
...
user
,
[
name
]:
value
})
}
if
(
data
.
buildingName
!==
""
)
{
extraAddress
+=
extraAddress
!==
""
?
`,
${
data
.
buildingName
}
`
:
data
.
buildingName
;
}
fullAddress
+=
extraAddress
!==
""
?
` (
${
extraAddress
}
)`
:
""
;
}
}
setAddress
({
full
:
fullAddress
,
zone
:
data
.
zonecode
});
console
.
log
(
fullAddress
);
}
const
Postcode
=
()
=>
{
return
(
<
DaumPostcode
onComplete
=
{
handleComplete
}
/
>
);
}
const
[
post
,
setPost
]
=
useState
([]);
function
postClick
()
{
if
(
post
.
length
!==
0
)
{
setPost
([])
}
else
{
setPost
(
<
div
>
<
DaumPostcode
style
=
{
postCodeStyle
}
onComplete
=
{
handleComplete
}
/
>
<
/div
>
)
}
}
const
postCodeStyle
=
{
position
:
"
absolute
"
,
width
:
"
400px
"
,
height
:
"
500px
"
,
padding
:
"
7px
"
,
};
const
[
validated
,
setValidated
]
=
useState
(
false
);
const
[
validated
,
setValidated
]
=
useState
(
false
);
const
handleSubmit
=
(
e
)
=>
{
async
function
handleSubmit
(
event
)
{
const
form
=
e
.
currentTarget
;
event
.
preventDefault
()
const
form
=
event
.
currentTarget
;
console
.
log
(
form
)
console
.
log
(
form
)
if
(
form
.
checkValidity
()
===
false
)
{
if
(
form
.
checkValidity
()
===
false
)
{
e
.
preventDefault
();
e
vent
.
preventDefault
();
e
.
stopPropagation
();
e
vent
.
stopPropagation
();
}
}
setValidated
(
true
);
setValidated
(
true
);
console
.
log
(
user
)
try
{
setError
(
''
)
const
response
=
await
fetch
(
'
/api/users/signup
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
(
user
)
})
const
data
=
await
response
.
json
()
console
.
log
(
data
)
}
catch
(
error
)
{
console
.
log
(
error
)
setError
(
'
다시 시도하세요.
'
)
}
}
}
return
(
return
(
...
@@ -83,37 +66,58 @@ function Signup() {
...
@@ -83,37 +66,58 @@ function Signup() {
<
Nav1
/>
<
Nav1
/>
<
Nav2
/>
<
Nav2
/>
<
Container
className
=
"
my-5
"
>
<
Container
className
=
"
my-5
"
>
{
error
&&
<
Alert
variant
=
'
danger
'
>
{
error
}
<
/Alert>
}
<
Row
className
=
"
justify-content-center
"
>
<
Row
className
=
"
justify-content-center
"
>
<
Col
md
=
{
6
}
xs
=
{
10
}
className
=
"
border
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
<
Col
md
=
{
6
}
xs
=
{
10
}
className
=
"
border
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
<
h2
className
=
"
text-center mt-5
"
>
Sign
Up
<
/h2
>
<
h2
className
=
"
text-center mt-5
"
>
Sign
Up
<
/h2
>
<
Form
noValidate
validated
=
{
validated
}
onSubmit
=
{
handleSubmit
}
className
=
"
p-5
"
>
<
Form
noValidate
validated
=
{
validated
}
onSubmit
=
{
handleSubmit
}
className
=
"
p-5
"
>
<
Form
.
Group
controlId
=
"
formBasicName
"
>
<
Form
.
Group
controlId
=
"
formBasicName
"
>
<
Form
.
Row
>
<
Form
.
Row
>
<
Form
.
Label
for
=
"
name
"
>
이
름
<
/Form.Label
>
<
Col
sm
=
{
4
}
xs
=
{
6
}
as
=
{
Form
.
Label
}
for
=
"
id
"
>
이
름
<
/Col
>
<
Col
sm
=
{
8
}
xs
=
{
12
}
as
=
{
Form
.
Control
}
required
type
=
"
text
"
name
=
"
name
"
placeholder
=
"
Name
"
style
=
{{
width
:
'
160px
'
}}
value
=
{
user
.
name
}
onChange
=
{
handleChange
}
/
>
<
Col
>
<
Form
.
Control
required
type
=
"
text
"
id
=
"
name
"
size
=
"
sm
"
placeholder
=
""
className
=
"
mx-sm-3
"
>
<
/Form.Control
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
이름을
입력하세요
.
<
/Form.Control.Feedback
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
이름을
입력하세요
.
<
/Form.Control.Feedback
>
<
/Col
>
<
/Form.Row
>
<
/Form.Row
>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
controlId
=
"
formBasicNumber
"
>
<
Form
.
Group
controlId
=
"
formBasicNumber
"
>
<
Form
.
Row
>
<
Form
.
Row
>
<
Form
.
Label
for
=
"
number
"
>
주민등록번호
<
/
Form.Labe
l
>
<
Col
sm
=
{
4
}
xs
=
{
6
}
as
=
{
Form
.
Label
}
for
=
"
number
"
>
주민등록번호
<
/
Co
l
>
<
Col
as
=
{
Row
}
>
<
Col
as
=
{
Row
}
sm
=
{
8
}
xs
=
{
12
}
>
<
Form
.
Control
required
type
=
"
text
"
id
=
"
number1
"
size
=
"
sm
"
maxlength
=
"
6
"
className
=
"
mx-sm-3
"
style
=
{{
width
:
'
120px
'
}}
><
/Form.Control
>
<
Form
.
Control
required
type
=
"
text
"
name
=
"
number1
"
maxlength
=
"
6
"
className
=
"
mx-2
"
style
=
{{
width
:
'
170px
'
}}
value
=
{
user
.
number1
}
onChange
=
{
handleChange
}
>
<
/Form.Control
>
-
-
<
Form
.
Control
required
type
=
"
text
"
id
=
"
number2
"
size
=
"
sm
"
maxlength
=
"
1
"
className
=
"
mx-sm-3
"
style
=
{{
width
:
'
25px
'
}}
><
/Form.Control
>
<
Form
.
Control
required
type
=
"
text
"
name
=
"
number2
"
maxlength
=
"
1
"
className
=
"
mx-3
"
style
=
{{
width
:
'
25px
'
}}
value
=
{
user
.
number2
}
onChange
=
{
handleChange
}
>
<
/Form.Control
>
******
******
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
주민등록번호를
입력하세요
.
<
/Form.Control.Feedback
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
주민등록번호를
입력하세요
.
<
/Form.Control.Feedback
>
<
/Col
>
<
/Col
>
...
@@ -122,65 +126,75 @@ function Signup() {
...
@@ -122,65 +126,75 @@ function Signup() {
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
controlId
=
"
formBasicId
"
>
<
Form
.
Group
controlId
=
"
formBasicId
"
>
<
Form
.
Row
>
<
Form
.
Row
>
<
Form
.
Label
for
=
"
id
"
>
아이디
<
/
Form.Labe
l
>
<
Col
sm
=
{
4
}
xs
=
{
6
}
as
=
{
Form
.
Label
}
for
=
"
id
"
>
아이디
<
/
Co
l
>
<
Col
>
<
Col
sm
=
{
8
}
xs
=
{
12
}
as
=
{
Form
.
Control
}
<
Form
.
Control
required
type
=
"
text
"
id
=
"
id
"
size
=
"
sm
"
placeholder
=
"
ID
"
className
=
"
mx-sm-3
"
><
/Form.Control
>
required
type
=
"
text
"
name
=
"
id
"
placeholder
=
"
ID
"
style
=
{{
width
:
'
160px
'
}}
value
=
{
user
.
id
}
onChange
=
{
handleChange
}
/
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
아이디를
입력하세요
.
<
/Form.Control.Feedback
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
아이디를
입력하세요
.
<
/Form.Control.Feedback
>
<
/Col
>
<
/Form.Row
>
<
/Form.Row
>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
controlId
=
"
formBasicPassword
"
>
<
Form
.
Group
controlId
=
"
formBasicPassword
"
>
<
Form
.
Row
>
<
Form
.
Row
>
<
Form
.
Label
for
=
"
password
"
>
비밀번호
<
/Form.Label
>
<
Col
sm
=
{
4
}
xs
=
{
6
}
as
=
{
Form
.
Label
}
for
=
"
password
"
>
비밀번호
<
/Col
>
<
Col
sm
=
{
8
}
xs
=
{
12
}
as
=
{
Form
.
Control
}
<
Col
>
type
=
"
password
"
<
Form
.
Control
required
type
=
"
password
"
id
=
"
password
"
size
=
"
sm
"
placeholder
=
"
Password
"
aria
-
describedby
=
"
passwordHelpBlock
"
className
=
"
mx-sm-3
"
><
/Form.Control
>
name
=
"
password
"
<
Form
.
Text
id
=
"
password
"
muted
>
8
-
15
자로
입력해주세요
.
<
/Form.Text
>
placeholder
=
"
Password
"
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
비밀번호를
입력하세요
.
style
=
{{
width
:
'
160px
'
}}
value
=
{
user
.
password
}
required
onChange
=
{
handleChange
}
/
>
<
Form
.
Control
.
Feedback
className
=
"
text-center
"
type
=
"
invalid
"
>
비밀번호를
입력하세요
.
<
/Form.Control.Feedback
>
<
/Form.Control.Feedback
>
<
/Col
>
<
/Form.Row
>
<
/Form.Row
>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
controlId
=
"
formBasicPassword2
"
>
<
Form
.
Group
controlId
=
"
formBasicPassword2
"
>
<
Form
.
Row
>
<
Form
.
Row
>
<
Form
.
Label
for
=
"
password2
"
>
비밀번호
확인
<
/Form.Label
>
<
Col
sm
=
{
4
}
xs
=
{
6
}
as
=
{
Form
.
Label
}
for
=
"
password
"
>
비밀번호
확인
<
/Col
>
<
Col
sm
=
{
8
}
xs
=
{
12
}
as
=
{
Form
.
Control
}
<
Col
>
type
=
"
password
"
<
Form
.
Control
required
type
=
"
password
"
id
=
"
password2
"
size
=
"
sm
"
placeholder
=
""
className
=
"
mx-sm-3
"
><
/Form.Control
>
name
=
"
password2
"
placeholder
=
"
Password
"
style
=
{{
width
:
'
160px
'
}}
value
=
{
user
.
password2
}
required
onChange
=
{
handleChange
}
/
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
비밀번호를
한번
더
입력하세요
.
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
비밀번호를
한번
더
입력하세요
.
<
/Form.Control.Feedback
>
<
/Form.Control.Feedback
>
<
/Col
>
<
/Form.Row
>
<
/Form.Row
>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
controlId
=
"
formBasicTel
"
>
<
Form
.
Group
controlId
=
"
formBasicTel
"
>
<
Form
.
Row
>
<
Form
.
Row
>
<
Form
.
Label
for
=
"
tel
"
>
휴대전화
<
/
Form.Labe
l
>
<
Col
sm
=
{
4
}
xs
=
{
6
}
as
=
{
Form
.
Label
}
for
=
"
tel
"
>
휴대전화
<
/
Co
l
>
<
Col
>
<
Col
sm
=
{
8
}
xs
=
{
12
}
as
=
{
Form
.
Control
}
<
Form
.
Control
required
type
=
"
text
"
id
=
"
tel
"
size
=
"
sm
"
placeholder
=
""
className
=
"
mx-sm-3
"
><
/Form.Control
>
required
type
=
"
text
"
name
=
"
tel
"
size
=
"
sm
"
style
=
{{
width
:
'
160px
'
}}
value
=
{
user
.
tel
}
onChange
=
{
handleChange
}
/
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
휴대전화를
입력하세요
.
<
/Form.Control.Feedback
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
휴대전화를
입력하세요
.
<
/Form.Control.Feedback
>
<
/Col
>
<
/Form.Row
>
<
/Form.Row
>
<
/Form.Group
>
<
/Form.Group
>
<
Form
.
Group
controlId
=
"
formBasicAdd
"
>
<
Button
<
Form
.
Row
>
style
=
{{
background
:
'
#91877F
'
,
borderColor
:
'
#91877F
'
}}
type
=
"
submit
"
block
>
{
console
.
log
(
"
address=
"
,
address
)}
Sign
Up
<
Form
.
Label
className
=
"
mx-3
"
>
주
소
<
/Form.Label
>
<
/Button
>
<
Form
.
Control
required
type
=
"
text
"
id
=
"
add
"
size
=
"
sm
"
style
=
{{
width
:
'
120px
'
}}
value
=
{
address
.
zone
}
disabled
=
{(
address
.
zone
==
null
)
?
false
:
true
}
><
/Form.Control>
<
Button
size
=
"
sm
"
style
=
{{
background
:
'
#91877F
'
,
borderColor
:
'
#91877F
'
}}
className
=
"
mx-3
"
type
=
"
button
"
onClick
=
{
postClick
}
>
주소
찾기
<
/Button
>
{
post
}
<
Form
.
Control
required
type
=
"
text
"
id
=
"
add
"
size
=
"
sm
"
value
=
{
address
.
full
}
disabled
=
{(
address
.
zone
==
null
)
?
false
:
true
}
className
=
"
mx-3
"
style
=
{{
width
:
'
330px
'
}}
><
/Form.Control
>
<
Form
.
Control
required
type
=
"
text
"
id
=
"
add2
"
size
=
"
sm
"
placeholder
=
"
상세주소
"
className
=
"
mx-sm-3
"
><
/Form.Control
>
<
Form
.
Control
.
Feedback
type
=
"
invalid
"
>
상세
주소를
입력하세요
.
<
/Form.Control.Feedback
>
<
/Form.Row
>
<
/Form.Group
>
<
Button
style
=
{{
background
:
'
#91877F
'
,
borderColor
:
'
#91877F
'
}}
type
=
"
submit
"
block
>
Sign
Up
<
/Button
>
<
/Form
>
<
/Form
>
<
/Col
>
<
/Col
>
...
...
server/config.js
View file @
ea8ae1a0
...
@@ -2,7 +2,7 @@ const config = {
...
@@ -2,7 +2,7 @@ const config = {
env
:
process
.
env
.
NODEENV
||
'
development
'
,
env
:
process
.
env
.
NODEENV
||
'
development
'
,
port
:
process
.
env
.
PORT
||
3001
,
port
:
process
.
env
.
PORT
||
3001
,
jwtSecret
:
process
.
env
.
JWT_SECRET
||
'
My_Secret_Key
'
,
jwtSecret
:
process
.
env
.
JWT_SECRET
||
'
My_Secret_Key
'
,
mongoDbUri
:
process
.
env
.
MONGEDB_URI
||
'
mongodb://localhost/
'
mongoDbUri
:
process
.
env
.
MONGEDB_URI
||
'
mongodb://localhost/
shopping-mall
'
}
}
export
default
config
export
default
config
\ No newline at end of file
server/controllers/user.controller.js
View file @
ea8ae1a0
import
User
from
"
../models/User.js
"
;
import
User
from
"
../models/User.js
"
;
import
isLength
from
'
validator/lib/isLength.js
'
const
signup
=
async
(
req
,
res
)
=>
{
const
signup
=
async
(
req
,
res
)
=>
{
const
{
name
,
email
,
password
}
=
req
.
body
const
{
name
,
number
,
id
,
password
,
password2
,
tel
}
=
req
.
body
try
{
try
{
if
(
!
isLength
(
password
,{
min
:
8
,
max
:
15
})){
return
res
.
status
(
422
).
send
(
'
비밀번호는 8-15자리로 입력해주세요.
'
)
}
const
newUser
=
await
new
User
({
const
newUser
=
await
new
User
({
name
,
name
,
email
,
number
,
password
id
,
password
,
password2
,
tel
}).
save
()
}).
save
()
console
.
log
(
newUser
)
console
.
log
(
newUser
)
res
.
json
(
newUser
)
res
.
json
(
newUser
)
...
...
server/models/User.js
View file @
ea8ae1a0
...
@@ -5,9 +5,9 @@ const { String } = mongoose.Schema.Types
...
@@ -5,9 +5,9 @@ const { String } = mongoose.Schema.Types
const
UserSchema
=
new
mongoose
.
Schema
({
const
UserSchema
=
new
mongoose
.
Schema
({
name
:
{
name
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
// 꼭 필요한 값
},
},
email
:
{
id
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
unique
:
true
,
unique
:
true
,
...
@@ -17,6 +17,17 @@ const UserSchema = new mongoose.Schema({
...
@@ -17,6 +17,17 @@ const UserSchema = new mongoose.Schema({
required
:
true
,
required
:
true
,
select
:
true
,
select
:
true
,
},
},
number
:{
type
:
String
,
required
:
true
,
select
:
true
,
unique
:
true
},
tel
:{
type
:
String
,
required
:
true
,
unique
:
true
},
role
:
{
role
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
...
server/package.json
View file @
ea8ae1a0
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
"type"
:
"module"
,
"type"
:
"module"
,
"main"
:
"app.js"
,
"main"
:
"app.js"
,
"scripts"
:
{
"scripts"
:
{
"dev"
:
"nodemon app.js"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
},
"keywords"
:
[],
"keywords"
:
[],
...
...
server/schemas/index.js
View file @
ea8ae1a0
...
@@ -4,9 +4,9 @@ import config from '../config.js';
...
@@ -4,9 +4,9 @@ import config from '../config.js';
const
connection
=
{}
const
connection
=
{}
async
function
connectDb
()
{
async
function
connectDb
()
{
//
if (connection.isConnection) {
if
(
connection
.
isConnection
)
{
//
return
return
//
}
}
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,
{
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,
{
useNewUrlParser
:
true
,
useNewUrlParser
:
true
,
...
...
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