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
f1611990
Commit
f1611990
authored
Jul 28, 2021
by
우지원
Browse files
0728
parent
c4b5738e
Changes
7
Hide whitespace changes
Inline
Side-by-side
client/src/apis/user.api.js
View file @
f1611990
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
const
getUser
=
async
(
id
)
=>
{
const
getUser
=
async
(
id
)
=>
{
// console.log('id222:',id.userID)
const
{
data
}
=
await
axios
.
get
(
`/api/getUser/
${
id
}
`
);
const
{
data
}
=
await
axios
.
get
(
`/api/getUser/
${
id
}
`
);
return
data
;
return
data
;
};
};
...
...
client/src/components/Home/CreateRoom.js
View file @
f1611990
...
@@ -24,7 +24,7 @@ const CreateRoom = () => {
...
@@ -24,7 +24,7 @@ const CreateRoom = () => {
},
[
room
]);
},
[
room
]);
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
console
.
log
(
room
)
//
console.log(room)
const
{
name
,
value
}
=
event
.
target
const
{
name
,
value
}
=
event
.
target
setRoom
({
...
room
,
[
name
]:
value
})
setRoom
({
...
room
,
[
name
]:
value
})
}
}
...
@@ -32,7 +32,7 @@ const CreateRoom = () => {
...
@@ -32,7 +32,7 @@ const CreateRoom = () => {
async
function
handleSubmit
(
e
)
{
async
function
handleSubmit
(
e
)
{
e
.
preventDefault
()
e
.
preventDefault
()
console
.
log
(
'
룸룸
'
,
room
)
//
console.log('룸룸', room)
try
{
try
{
const
res
=
await
roomApi
.
create
(
room
)
const
res
=
await
roomApi
.
create
(
room
)
// console.log(res)
// console.log(res)
...
...
client/src/components/Home/HomeProfile.js
View file @
f1611990
...
@@ -16,11 +16,11 @@ const HomeProfile = () => {
...
@@ -16,11 +16,11 @@ const HomeProfile = () => {
async
function
getSetUser
(
userID
)
{
async
function
getSetUser
(
userID
)
{
try
{
try
{
console
.
log
(
'
userID
'
,
userID
)
//
console.log('userID', userID)
const
data
=
await
userApi
.
getUser
(
{
userID
}
)
const
data
=
await
userApi
.
getUser
(
userID
)
console
.
log
(
data
)
//
console.log(data)
setUser
(
data
)
setUser
(
data
)
console
.
log
(
user
)
//
console.log(user)
}
catch
(
error
)
{
}
catch
(
error
)
{
// catchErrors(error, setError)
// catchErrors(error, setError)
}
}
...
...
client/src/components/Home/JoinRoom.js
View file @
f1611990
...
@@ -18,7 +18,7 @@ const JoinRoom = () => {
...
@@ -18,7 +18,7 @@ const JoinRoom = () => {
function
handleChange
(
event
)
{
function
handleChange
(
event
)
{
const
{
value
}
=
event
.
target
;
const
{
value
}
=
event
.
target
;
setRoomId
(
value
);
setRoomId
(
value
);
console
.
log
(
roomId
);
//
console.log(roomId);
}
}
async
function
handleSubmit
(
e
)
{
async
function
handleSubmit
(
e
)
{
...
@@ -26,10 +26,10 @@ const JoinRoom = () => {
...
@@ -26,10 +26,10 @@ const JoinRoom = () => {
try
{
try
{
// setLoading(true);
// setLoading(true);
// setError("");
// setError("");
console
.
log
(
'
userId:
'
,
userId
)
//
console.log('userId:', userId)
console
.
log
(
'
roomId:
'
,
roomId
)
//
console.log('roomId:', roomId)
const
data
=
await
roomApi
.
join
({
userId
:
userId
,
roomId
:
roomId
});
const
data
=
await
roomApi
.
join
({
userId
:
userId
,
roomId
:
roomId
});
console
.
log
(
data
);
//
console.log(data);
setSuccess
(
true
);
setSuccess
(
true
);
}
catch
(
error
)
{
}
catch
(
error
)
{
// catchErrors(error, setError);
// catchErrors(error, setError);
...
...
controllers/room.controller.js
View file @
f1611990
...
@@ -36,7 +36,7 @@ const joinRoom = async (req, res) => {
...
@@ -36,7 +36,7 @@ const joinRoom = async (req, res) => {
};
};
const
createRoom
=
async
(
req
,
res
)
=>
{
const
createRoom
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
룸정보
'
,
req
.
body
)
//
console.log('룸정보', req.body)
const
{
name
,
owner
,
member
,
profileimg
}
=
req
.
body
;
const
{
name
,
owner
,
member
,
profileimg
}
=
req
.
body
;
const
id
=
nanoid
()
const
id
=
nanoid
()
const
Id
=
await
Room
.
findOne
({
where
:
{
id
:
id
}
});
const
Id
=
await
Room
.
findOne
({
where
:
{
id
:
id
}
});
...
...
controllers/user.controller.js
View file @
f1611990
...
@@ -5,14 +5,15 @@ import isLength from 'validator/lib/isLength.js'
...
@@ -5,14 +5,15 @@ import isLength from 'validator/lib/isLength.js'
import
bcrypt
from
"
bcryptjs
"
;
import
bcrypt
from
"
bcryptjs
"
;
const
getUser
=
async
(
req
,
res
)
=>
{
const
getUser
=
async
(
req
,
res
)
=>
{
const
user
=
await
User
.
findOne
({
where
:
{
id
:
req
.
body
.
id
}
});
// console.log('req.params:',req.params)
console
.
log
(
'
user:
'
,
user
)
const
user
=
await
User
.
findOne
({
where
:
{
id
:
req
.
params
.
id
}
});
// console.log('user:',user)
res
.
json
(
user
)
res
.
json
(
user
)
};
};
const
login
=
async
(
req
,
res
)
=>
{
const
login
=
async
(
req
,
res
)
=>
{
try
{
try
{
console
.
log
(
'
login=
'
,
req
.
body
)
//
console.log('login= ', req.body)
const
{
email
,
password
}
=
req
.
body
const
{
email
,
password
}
=
req
.
body
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
const
user
=
await
User
.
findOne
({
where
:
{
email
:
email
}
})
if
(
!
user
)
{
if
(
!
user
)
{
...
@@ -34,19 +35,19 @@ const login = async (req, res) => {
...
@@ -34,19 +35,19 @@ const login = async (req, res) => {
}
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
//
console.log(error)
return
res
.
status
(
500
).
send
(
'
로그인 중 에러
'
)
return
res
.
status
(
500
).
send
(
'
로그인 중 에러
'
)
}
}
}
}
const
signup
=
async
(
req
,
res
)
=>
{
const
signup
=
async
(
req
,
res
)
=>
{
try
{
try
{
console
.
log
(
'
sign up=
'
,
req
.
body
)
//
console.log('sign up= ', req.body)
const
{
name
,
email
,
password
,
gender
,
phone
}
=
req
.
body
const
{
name
,
email
,
password
,
gender
,
phone
}
=
req
.
body
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
console
.
log
(
'
id:
'
,
id
)
//
console.log('id:', id)
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
console
.
log
(
'
Id 중복확인:
'
,
Id
)
//
console.log('Id 중복확인:', Id)
while
(
Id
)
{
while
(
Id
)
{
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
const
id
=
Math
.
floor
(
Math
.
random
()
*
(
9999
-
1000
)
+
1000
)
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
const
Id
=
await
User
.
findOne
({
where
:
{
id
:
id
}
})
...
@@ -70,9 +71,7 @@ const signup = async (req, res) => {
...
@@ -70,9 +71,7 @@ const signup = async (req, res) => {
password
:
password
,
password
:
password
,
gender
:
gender
,
gender
:
gender
,
phone
:
phone
,
phone
:
phone
,
}).
then
(
_
=>
})
console
.
log
(
'
회원가입 정보
'
,
id
,
name
,
email
,
password
,
gender
,
phone
),
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
return
res
.
status
(
500
).
send
(
'
회원가입 중 에러
'
)
return
res
.
status
(
500
).
send
(
'
회원가입 중 에러
'
)
...
...
routes/user.route.js
View file @
f1611990
...
@@ -3,7 +3,7 @@ import userCtrl from "../controllers/user.controller.js";
...
@@ -3,7 +3,7 @@ import userCtrl from "../controllers/user.controller.js";
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
router
.
route
(
"
/getUser
"
).
get
(
userCtrl
.
getUser
);
router
.
route
(
"
/getUser
/:id
"
).
get
(
userCtrl
.
getUser
);
router
.
route
(
"
/login
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/login
"
).
post
(
userCtrl
.
login
);
router
.
route
(
"
/signup
"
).
post
(
userCtrl
.
signup
);
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