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
6ddc36e4
Commit
6ddc36e4
authored
Jul 16, 2021
by
seoyeon
Browse files
0716
parent
b5ae019d
Changes
6
Show whitespace changes
Inline
Side-by-side
client/package.json
View file @
6ddc36e4
...
@@ -40,5 +40,6 @@
...
@@ -40,5 +40,6 @@
"last 1 firefox version"
,
"last 1 firefox version"
,
"last 1 safari version"
"last 1 safari version"
]
]
}
},
"proxy"
:
"http://localhost:8080"
}
}
client/src/apis/user.api.js
View file @
6ddc36e4
...
@@ -7,4 +7,12 @@ const login = async (email, password) => {
...
@@ -7,4 +7,12 @@ const login = async (email, password) => {
return
data
;
return
data
;
};
};
export
default
login
;
// const signup = async (email, password) => {
// const payload = { email, password, phone, gender } = req.body;
// const { data } = await axios.post(`${endpoints.API_BASE_URL}/`, payload);
// return data;
// }
export
default
{
login
,
// signup
};
client/src/components/Login.js
View file @
6ddc36e4
...
@@ -37,6 +37,10 @@ const Login = () => {
...
@@ -37,6 +37,10 @@ const Login = () => {
}
}
}
}
if
(
success
)
{
alert
(
'
로그인 되었습니다
'
)
}
const
{
email
,
password
}
=
user
;
const
{
email
,
password
}
=
user
;
return
(
return
(
...
...
client/src/components/SignUp.js
View file @
6ddc36e4
...
@@ -49,6 +49,11 @@ const Signup = () => {
...
@@ -49,6 +49,11 @@ const Signup = () => {
}
}
}
}
if
(
success
)
{
alert
(
'
회원가입 되었습니다.
'
)
}
const
{
name
,
idNumber1
,
idNumber2
,
id
,
password
,
checkpw
,
phone
}
=
user
;
const
{
name
,
idNumber1
,
idNumber2
,
id
,
password
,
checkpw
,
phone
}
=
user
;
return
(
return
(
<
div
className
=
"
modal-content
"
>
<
div
className
=
"
modal-content
"
>
...
...
controllers/user.controller.js
View file @
6ddc36e4
import
{
User
}
from
"
../models/index.js
"
;
import
{
User
}
from
"
../models/index.js
"
;
import
config
from
"
../config/app.config.js
"
;
import
config
from
"
../config/app.config.js
"
;
import
isLength
from
'
validator/lib/isLength.js
'
import
bcrypt
from
"
bcryptjs
"
;
const
login
=
async
(
req
,
res
)
=>
{
const
login
=
async
(
req
,
res
)
=>
{
try
{
try
{
...
@@ -29,6 +31,35 @@ const login = async (req, res) => {
...
@@ -29,6 +31,35 @@ const login = async (req, res) => {
}
}
};
};
const
signup
=
async
(
req
,
res
)
=>
{
try
{
console
.
log
(
'
signup=
'
,
req
.
body
);
const
{
name
,
password
,
id
}
=
req
.
body
;
if
(
!
isLength
(
name
,
{
min
:
3
,
max
:
10
}))
{
return
res
.
status
(
422
).
send
(
'
이름은 3-10자 사이입니다
'
)
}
else
if
(
!
isLength
(
password
,
{
min
:
6
}))
{
return
res
.
status
(
422
).
send
(
'
비밀번호는 6자 이상입니다
'
)
}
else
if
(
!
isLength
(
id
,
{
min
:
3
,
max10
}))
{
return
res
.
status
(
422
).
send
(
'
아이디는 3-10자 사이입니다
'
)
}
const
user
=
await
User
.
scope
(
"
password
"
).
findOne
({
where
:
email
});
if
(
user
)
return
res
.
status
(
422
).
send
(
`
${
email
}
이미 존재하는 사용자입니다/+ `
);
const
hash
=
await
bcrypt
.
hash
(
password
,
10
)
const
newUser
=
await
new
User
({
name
,
password
:
hash
,
id
}).
save
()
console
.
log
(
newUser
)
res
.
json
(
newUser
)
}
catch
(
error
)
{
console
.
log
(
error
);
return
res
.
status
(
500
).
send
(
"
회원가입 중 에러
"
)
}
}
export
default
{
export
default
{
login
,
login
,
signup
};
};
routes/user.route.js
View file @
6ddc36e4
...
@@ -5,4 +5,5 @@ const router = express.Router();
...
@@ -5,4 +5,5 @@ const router = express.Router();
router
.
route
(
"
/
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/
"
).
post
(
userCtrl
.
signup
);
export
default
router
;
export
default
router
;
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