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
messenger
Commits
35b35878
Commit
35b35878
authored
Jan 18, 2021
by
우지원
Browse files
Merge remote-tracking branch 'origin/young' into jiweon827
parents
b1f271f9
db5383e3
Changes
5
Show whitespace changes
Inline
Side-by-side
client/src/Components/ClosedList.js
View file @
35b35878
import
axios
from
'
axios
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
import
React
,
{
useState
}
from
'
react
'
import
{
ListGroup
,
Row
,
Col
}
from
'
react-bootstrap
'
;
import
{
ListGroup
,
Row
,
Col
}
from
'
react-bootstrap
'
;
import
axios
from
'
axios
'
function
ClosedList
(
props
)
{
function
ClosedList
(
props
)
{
const
[
list
,
setList
]
=
useState
([]);
const
[
list
,
setList
]
=
useState
([]);
// async function getClosedList() { //email로 db에서 찾아오기 ㅇㅇㅇㅇㅇ
useEffect
(()
=>
{
// const member = sessionStorage.getItem('name')
getClosedList
();
// const response = await axios.put(`/room/${member}`, { 'member': member })
},
[]);
// setList(response.data)
// }
// console.log(list)
async
function
getClosedList
()
{
let
res
=
await
axios
.
get
(
'
/room/closedlist
'
)
console
.
log
(
'
가져온거
'
,
res
)
setList
(
res
.
data
)
}
function
enterChatroomCH
(
e
)
{
function
enterChatroomCH
(
e
)
{
console
.
log
(
e
.
target
.
name
)
console
.
log
(
e
.
target
.
name
)
...
@@ -29,8 +30,8 @@ function ClosedList(props) {
...
@@ -29,8 +30,8 @@ function ClosedList(props) {
<
div
>
<
div
>
{
list
.
map
((
item
,
index
)
=>
{
list
.
map
((
item
,
index
)
=>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
key
=
{
index
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatroomCH
}
name
=
{
item
.
room
}
>
<
ListGroup
.
Item
action
onClick
=
{
enterChatroomCH
}
name
=
{
item
.
room
Name
}
>
{
item
.
room
}
{
item
.
room
Name
}
<
/ListGroup.Item
>
<
/ListGroup.Item
>
<
/ListGroup
>
<
/ListGroup
>
)}
)}
...
...
client/src/Pages/HomePage.js
View file @
35b35878
server/controllers/room.controller.js
View file @
35b35878
...
@@ -19,7 +19,7 @@ const makeRoom = async (req, res) => {
...
@@ -19,7 +19,7 @@ const makeRoom = async (req, res) => {
try
{
try
{
if
(
!
isLength
(
roomName
,
{
min
:
3
,
max
:
20
}))
{
if
(
!
isLength
(
roomName
,
{
min
:
3
,
max
:
20
}))
{
return
res
.
status
(
422
).
send
(
'
채팅방의 이름은 3-20자여야 합니다.
'
)
return
res
.
status
(
422
).
send
(
'
채팅방의 이름은 3-20자여야 합니다.
'
)
}
else
if
(
interest
==
'
Choose...
'
||
interest
==
''
){
}
else
if
(
interest
==
'
Choose...
'
||
interest
==
''
)
{
return
res
.
status
(
422
).
send
(
'
분야를 반드시 선택하여야 합니다.
'
)
return
res
.
status
(
422
).
send
(
'
분야를 반드시 선택하여야 합니다.
'
)
}
}
const
newRoom
=
await
new
Room
({
const
newRoom
=
await
new
Room
({
...
@@ -37,14 +37,14 @@ const makeRoom = async (req, res) => {
...
@@ -37,14 +37,14 @@ const makeRoom = async (req, res) => {
}
}
}
}
//
const
checkmember
= async (req, res) => {
const
getClosedList
=
async
(
req
,
res
)
=>
{
//
try {
try
{
//
let
user
= await Room.find
One(req.body).select('roomName').exec(
)
let
list
=
await
Room
.
find
({
isOpen
:
false
}
)
//
console.log(
user
)
console
.
log
(
'
list가져오기
'
,
list
)
//
return res.json(
user
)
return
res
.
json
(
list
)
//
} catch (error) {
}
catch
(
error
)
{
//
alert('올바르지 못한 접근입
니다
.
')
res
.
status
(
500
).
send
(
'
리스트 불러오기를 실패하였습
니다
!
'
)
//
}
}
//
}
}
export
default
{
makeRoom
}
export
default
{
makeRoom
,
getClosedList
}
\ No newline at end of file
server/controllers/user.controller.js
View file @
35b35878
...
@@ -2,8 +2,7 @@ import User from "../models/User.js"
...
@@ -2,8 +2,7 @@ import User from "../models/User.js"
import
isLength
from
'
validator/lib/isLength.js
'
import
isLength
from
'
validator/lib/isLength.js
'
import
isEmail
from
'
validator/lib/isEmail.js
'
import
isEmail
from
'
validator/lib/isEmail.js
'
import
bcrypt
from
"
bcryptjs
"
;
import
bcrypt
from
"
bcryptjs
"
;
import
jwt
from
'
jsonwebtoken
'
import
config
from
"
../config.js
"
const
signup
=
async
(
req
,
res
)
=>
{
const
signup
=
async
(
req
,
res
)
=>
{
...
@@ -62,21 +61,12 @@ const changenick = async (req, res) => {
...
@@ -62,21 +61,12 @@ const changenick = async (req, res) => {
}
}
}
}
const
loginNavbar
=
async
(
req
,
res
)
=>
{
// const saveroom = async (req, res) => {
try
{
// const roomId = room.roomId
let
user
=
await
User
.
findOne
(
req
.
body
).
select
(
'
username
'
).
exec
()
// if (!isLength(roomId, { min: 11 })) {
return
res
.
json
(
user
)
// return res.status(422).send('방아이디 저장에 오류가 발생하였습니다.')
}
catch
(
error
)
{
// }
alert
(
'
올바르지 못한 접근입니다.
'
)
// }
}
}
const
saveroom
=
async
(
req
,
res
)
=>
{
const
roomId
=
room
.
roomId
if
(
!
isLength
(
roomId
,
{
min
:
11
}))
{
return
res
.
status
(
422
).
send
(
'
방아이디 저장에 오류가 발생하였습니다.
'
)
}
}
export
default
{
signup
,
logineduser
,
changenick
,
loginNavbar
,
saveroom
}
export
default
{
signup
,
logineduser
,
changenick
}
// {} : 객체로 return 함
// {} : 객체로 return함
\ No newline at end of file
server/routes/room.routers.js
View file @
35b35878
...
@@ -6,7 +6,6 @@ const router = express.Router()
...
@@ -6,7 +6,6 @@ const router = express.Router()
router
.
route
(
'
/room/makeRoom
'
)
router
.
route
(
'
/room/makeRoom
'
)
.
post
(
roomCtrl
.
makeRoom
)
.
post
(
roomCtrl
.
makeRoom
)
// router.route(`/room/:member`)
router
.
route
(
'
/room/closedlist
'
)
// .put(userCtrl.checkmember)
.
get
(
roomCtrl
.
getClosedList
)
export
default
router
export
default
router
\ No newline at end of file
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