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
reservation-service
Commits
7de8fc28
Commit
7de8fc28
authored
Nov 06, 2020
by
Kim, Subin
Browse files
교수님 여기요! 11.06.04:00
parent
3ed89fa4
Changes
22
Hide whitespace changes
Inline
Side-by-side
server/client/package-lock.json
View file @
7de8fc28
This source diff could not be displayed because it is too large. You can
view the blob
instead.
server/client/src/Components/AdminPrivateRoute.js
0 → 100644
View file @
7de8fc28
// import React from 'react';
// import { Redirect, Route } from "react-router-dom";
// export const AdminPrivateRoute = ({ component: Component, ...rest }) => (
// <Route
// {...rest}
// render={props =>
// (localStorage.getItem("token") !==null) ? (
// <Component {...props} />
// ) : (
// <Redirect to={{
// pathname: "/login",
// state: {match: props.location}
// }} />
// )
// }
// />
// )
\ No newline at end of file
server/client/src/Components/Card.js
View file @
7de8fc28
...
...
@@ -73,7 +73,7 @@ function Notice({ card_id, card_index, title, date, content, admin }) {
})}
{
admin
===
"
admin
"
?
(
<
div
className
=
"
d-flex justify-content-end
"
>
<
Button
variant
=
"
primary
"
size
=
"
sm
"
as
=
{
Link
}
to
=
{
`/
write/revise
/
${
card_id
}
`
}
>
수정
<
/Button
>
<
Button
variant
=
"
primary
"
size
=
"
sm
"
as
=
{
Link
}
to
=
{
`/
modify
/
${
card_id
}
`
}
>
수정
<
/Button
>
<
Button
variant
=
"
danger
"
size
=
"
sm
"
onClick
=
{()
=>
remove
(
card_id
)}
>
삭제
<
/Button
>
<
/div>
)
: null
}
<
/Text
>
...
...
server/client/src/Components/Menu.js
View file @
7de8fc28
...
...
@@ -31,7 +31,6 @@ function Menu() {
axios
.
get
(
`/users/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
}).
then
(
res
=>
{
console
.
log
(
res
.
data
)
if
(
res
.
data
.
role
==
"
admin
"
)
{
setUser
(
res
.
data
)
}
...
...
server/client/src/Pages/ACheckPage.js
View file @
7de8fc28
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
axios
from
'
axios
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
{
Container
,
Table
}
from
'
react-bootstrap
'
;
import
styled
from
'
styled-components
'
;
...
...
@@ -20,7 +20,6 @@ const Ta = styled(Table)`
align-items: center;
width: 70px;
};
`
function
ACheck
(
props
)
{
...
...
@@ -40,7 +39,6 @@ function ACheck(props) {
alert
(
res
.
data
.
error
)
setState
(
true
);
}
console
.
log
(
res
.
data
);
setReserve
(
res
.
data
);
})
.
catch
(
err
=>
{
...
...
@@ -81,7 +79,6 @@ function ACheck(props) {
<
Container
fluid
>
<
Ta
responsive
=
"
lg
"
>
<
thead
className
=
"
thead-light
"
>
<
tr
>
<
th
>
대표자
<
/th
>
<
th
>
날짜
<
/th
>
...
...
server/client/src/Pages/ApplyPage.js
View file @
7de8fc28
...
...
@@ -55,7 +55,6 @@ function Apply(props) {
localStorage
.
clear
();
setState
({
ok
:
"
no
"
});
}
console
.
log
(
res
.
data
);
setUser
(
res
.
data
);
})
.
catch
(
err
=>
{
...
...
@@ -110,7 +109,6 @@ function Apply(props) {
}
alert
(
"
신청이 완료되었습니다!
"
);
setState
({
ok
:
"
ok
"
});
console
.
log
(
"
res.data
"
,
res
.
data
)
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
...
...
@@ -179,9 +177,9 @@ function Apply(props) {
<
div
className
=
{
touched
.
room
&&
errors
.
room
?
"
text-danger
"
:
""
}
>
강의실
<
/div
>
<
Field
as
=
"
select
"
name
=
"
room
"
className
=
"
col-6
"
>
<
option
value
=
""
>
강의실
선택
<
/option
>
<
option
value
=
"
9-116
"
>
9
-
116
<
/option
>
<
option
value
=
"
7-234
"
>
7
-
234
<
/option
>
<
option
value
=
"
25-101
"
>
25
-
101
<
/option
>
<
option
value
=
"
9-116
"
>
9
-
116
(
5
명
)
<
/option
>
<
option
value
=
"
7-234
"
>
7
-
234
(
7
명
)
<
/option
>
<
option
value
=
"
25-101
"
>
25
-
101
(
10
명
)
<
/option
>
<
/Field
>
<
/div
>
...
...
@@ -198,7 +196,7 @@ function Apply(props) {
<
div
className
=
"
form-group mb-4
"
>
<
FieldArray
name
=
"
students
"
>
{({
insert
,
remove
,
push
})
=>
(
{({
remove
,
push
})
=>
(
<
div
>
<
div
className
=
{
touched
.
date
&&
errors
.
date
?
"
text-danger
"
:
""
}
>
이용자
<
/div
>
{
values
.
students
.
map
((
student
,
index
)
=>
(
...
...
server/client/src/Pages/ChangePage.js
View file @
7de8fc28
...
...
@@ -8,7 +8,6 @@ import { Container, Button, Navbar, Col } from 'react-bootstrap';
import
styled
from
'
styled-components
'
;
const
Check
=
styled
.
div
`
& #reCheck::after {
content: '새로운 비밀번호를 다시 입력하세요';
}
...
...
@@ -26,7 +25,7 @@ function Change(props) {
if
(
state
)
{
return
<
Redirect
to
=
"
/
"
/>
;
}
// console.log(props)
return
(
<
div
className
=
""
>
{(
localStorage
.
getItem
(
"
token
"
)
!==
null
)
?
(
...
...
@@ -103,13 +102,10 @@ function Change(props) {
)}
<
/Formik
>
<
/Col
>
<
/Check
>
<
/Container
>
<
/div
>
);
}
export
default
Change
;
export
default
Change
\ No newline at end of file
server/client/src/Pages/CheckPage.js
View file @
7de8fc28
...
...
@@ -6,7 +6,7 @@ import { Container, Table } from 'react-bootstrap';
import
styled
from
'
styled-components
'
;
const
Ta
=
styled
(
Table
)
`
margin-top: 0.5em;
margin-top: 0.5em;
& th, & td {
padding: 0;
...
...
@@ -49,7 +49,6 @@ function Check(props) {
localStorage
.
clear
();
setState
(
true
);
}
console
.
log
(
res
.
data
);
const
reserves
=
res
.
data
.
filter
(
function
(
item
)
{
return
item
!==
''
;
});
...
...
@@ -110,4 +109,4 @@ function Check(props) {
)
}
export
default
Check
export
default
Check
\ No newline at end of file
server/client/src/Pages/FindPage.js
View file @
7de8fc28
...
...
@@ -23,6 +23,7 @@ function Find() {
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
}}
/>
;
}
return
(
<
div
className
=
"
vh-100
"
>
<
Menu
expand
=
"
md
"
variant
=
"
dark
"
>
...
...
@@ -111,4 +112,4 @@ function Find() {
}
export
default
Find
;
export
default
Find
\ No newline at end of file
server/client/src/Pages/HomePage.js
View file @
7de8fc28
...
...
@@ -45,7 +45,7 @@ function Home() {
<
p
>
<
strong
>
유의사항
<
/strong
>
<
ul
className
=
"
pl-4
"
>
<
li
>
강의실
을
대관하는
대표자를
기준으로
최대
주
6
시간까지
대관이
가능
합니다
.
<
/li
>
<
li
>
강의실
사용시
최소인원
수에
맞춰서
명단
작성이
필요
합니다
.
<
/li
>
<
li
>
1
회
대관시
최대
3
시간까지
이용이
가능합니다
.
(
1
시간
단위로
대관
가능
)
<
/li
>
<
li
><
strong
style
=
{{
color
:
"
red
"
}}
>
대관
시간
이외
강의실을
이용하다
적발될
경우
한달
간
강의실
이용이
불가합니다
.
<
/strong></
li
>
<
/ul
>
...
...
@@ -66,4 +66,4 @@ function Home() {
)
}
export
default
Home
;
\ No newline at end of file
export
default
Home
\ No newline at end of file
server/client/src/Pages/LoginPage.js
View file @
7de8fc28
...
...
@@ -27,7 +27,6 @@ const Col_1 = styled.div`
height : 100%;
width: 100%;
justify-content: space-evenly;
}
& .mob-img {
...
...
@@ -177,10 +176,8 @@ function Login() {
<
/div
>
<
Button
type
=
"
submit
"
variant
=
"
dark
"
className
=
{
mobile
?
"
w-100
"
:
"
w-20
"
}
disabled
=
{
isSubmitting
}
>
Login
<
/Button
>
<
/div
>
<
div
><
Link
to
=
"
/find
"
>
비밀번호를
잊으셨나요
?
<
/Link></
div
>
<
div
><
Link
to
=
"
/signup
"
>
회원이
아니신가요
?
<
/Link></
div
>
<
/form
>
<
/div
>
)}
...
...
@@ -188,8 +185,7 @@ function Login() {
<
/Col_2
>
<
/Row
>
<
/Container
>
)
}
export
default
Login
;
\ No newline at end of file
export
default
Login
\ No newline at end of file
server/client/src/Pages/ModifyPage.js
0 → 100644
View file @
7de8fc28
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
Menu
from
'
../Components/Menu
'
;
import
*
as
Yup
from
'
yup
'
;
import
axios
from
'
axios
'
;
import
{
Container
,
Row
,
Col
,
Button
}
from
'
react-bootstrap
'
;
import
{
Field
,
Formik
}
from
'
formik
'
;
function
Modify
({
match
})
{
const
[
state
,
setState
]
=
useState
(
false
);
const
[
modification
,
setModification
]
=
useState
({
title
:
""
,
content
:
""
});
const
[
isadmin
,
setIsadmin
]
=
useState
({
ok
:
""
});
const
[
user
,
setUser
]
=
useState
({
name
:
""
,
role
:
""
})
useEffect
(()
=>
{
acheck
();
getOne
(
match
.
params
.
id
);
},
[])
if
(
isadmin
.
ok
===
"
no
"
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
)
{
return
<
Redirect
to
=
"
/notice
"
/>
;
}
function
getOne
(
id
)
{
if
(
id
)
{
axios
.
get
(
`/notices/
${
match
.
params
.
id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
}
setModification
({
title
:
res
.
data
.
notice_title
,
content
:
res
.
data
.
notice_content
})
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
};
function
acheck
()
{
axios
.
get
(
`/users/admin/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
setIsadmin
({
ok
:
"
no
"
});
}
setUser
({
name
:
res
.
data
.
name
,
role
:
res
.
data
.
role
})
}).
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
return
(
<
div
>
<
Menu
/>
<
Container
fluid
>
{
console
.
log
(
modification
)}
<
Row
className
=
"
justify-content-center
"
>
<
Col
md
=
{
5
}
xs
=
{
11
}
className
=
"
pt-3
"
>
<
Formik
initialValues
=
{{
name
:
user
.
name
,
title
:
modification
.
title
,
content
:
modification
.
content
}}
enableReinitialize
=
{
true
}
validationSchema
=
{
Yup
.
object
({
title
:
Yup
.
string
()
.
required
(
'
제목을 입력해주세요.
'
),
content
:
Yup
.
string
()
.
required
(
'
내용을 입력해주세요.
'
),
})}
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
axios
({
method
:
'
put
'
,
url
:
`/writes/
${
match
.
params
.
id
}
`
,
data
:
values
,
})
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
공지 수정이 완료되었습니다.
"
)
setState
(
true
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
setTimeout
(()
=>
{
setSubmitting
(
false
);
},
400
);
// finish the cycle in handler
}}
>
{({
errors
,
touched
,
handleSubmit
,
getFieldProps
,
// contain values, handleChange, handleBlur
isSubmitting
,
})
=>
(
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
d-flex flex-column
"
>
<
div
className
=
"
form-group
"
>
<
div
className
=
{
touched
.
name
&&
errors
.
name
?
"
text-danger
"
:
""
}
>
제목
<
/div
>
<
input
className
=
{(
touched
.
name
&&
errors
.
name
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
title
=
"
title
"
{...
getFieldProps
(
'
title
'
)}
disabled
/>
<
/div
>
<
div
className
=
"
form-group
"
>
<
div
className
=
{
touched
.
name
&&
errors
.
name
?
"
text-danger
"
:
""
}
>
내용
<
/div
>
<
Field
as
=
"
textarea
"
rows
=
{
8
}
style
=
{{
"
min-width
"
:
"
100%
"
}}
{...
getFieldProps
(
'
content
'
)}
/
>
<
/div
>
<
Button
className
=
"
mb-2
"
variant
=
"
dark
"
type
=
"
submit
"
disabled
=
{
isSubmitting
}
>
공지
수정
<
/Button
>
<
/form
>
)}
<
/Formik
>
<
/Col
>
<
/Row
>
<
/Container
>
<
/div
>
)
}
export
default
Modify
\ No newline at end of file
server/client/src/Pages/NoticePage.js
View file @
7de8fc28
...
...
@@ -67,4 +67,4 @@ function Notice() {
)
}
export
default
Notice
;
\ No newline at end of file
export
default
Notice
\ No newline at end of file
server/client/src/Pages/SignupPage.js
View file @
7de8fc28
...
...
@@ -157,8 +157,7 @@ function Signup() {
<
/Wow
>
<
/Container
>
<
/div
>
);
}
export
default
Signup
;
\ No newline at end of file
export
default
Signup
\ No newline at end of file
server/client/src/Pages/WritePage.js
View file @
7de8fc28
...
...
@@ -6,69 +6,46 @@ import axios from 'axios';
import
{
Container
,
Row
,
Col
,
Button
}
from
'
react-bootstrap
'
;
import
{
Field
,
Formik
}
from
'
formik
'
;
function
Write
(
{
match
}
)
{
function
Write
()
{
const
[
state
,
setState
]
=
useState
(
false
);
const
[
revision
,
setRevision
]
=
useState
({
title
:
''
,
content
:
''
});
// const [isadmin, setIsadmin] = useState({ok:""});
// const [user, setUser] = useState({ role: "" })
// if (isadmin.ok==="no") return <Redirect to="/" />;
const
[
isadmin
,
setIsadmin
]
=
useState
({
ok
:
""
});
const
[
user
,
setUser
]
=
useState
({
name
:
""
})
useEffect
(()
=>
{
getOne
(
match
.
params
.
id
)
acheck
();
},
[])
if
(
isadmin
.
ok
===
"
no
"
)
return
<
Redirect
to
=
"
/
"
/>
;
if
(
state
)
{
return
<
Redirect
to
=
"
/notice
"
/>
;
}
function
getOne
(
id
)
{
if
(
id
)
{
axios
.
get
(
`/notices/
${
id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
}
setRevision
({
title
:
res
.
data
.
notice_title
,
content
:
res
.
data
.
notice_content
})
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
};
// function putData (match, revision) {
// if (!match.params.id) return { title: '', content: '' }
// else return { title: revision.notice_title, content: revision.notice_content }
// };
// function acheck() {
// axios.get(`/users/${localStorage.getItem('_id')}`, {
// headers: { authorization: localStorage.getItem('token') },
// })
// .then(res => {
// if (res.status !== 201) {
// alert(res.data.error);
// localStorage.clear();
// setIsadmin({ok:"no"});
// }
// if (res.data.role == "admin") {
// setUser(res.data)
// }
// }).catch(err => {
// alert(err.error)
// });
// }
function
acheck
()
{
axios
.
get
(
`/users/admin/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
console
.
log
(
res
.
data
)
setIsadmin
({
ok
:
"
no
"
});
}
setUser
({
name
:
res
.
data
.
name
})
}).
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
return
(
<
div
>
{
console
.
log
(
"
revision
"
,
revision
.
title
,
revision
.
content
)}
<
Menu
/>
<
Menu
/>
<
Container
fluid
>
<
Row
className
=
"
justify-content-center
"
>
<
Col
md
=
{
5
}
xs
=
{
11
}
className
=
"
pt-3
"
>
<
Formik
initialValues
=
{{
title
:
revision
.
title
,
content
:
revision
.
content
}}
initialValues
=
{{
name
:
user
.
name
,
title
:
''
,
content
:
''
}}
enableReinitialize
=
{
true
}
validationSchema
=
{
Yup
.
object
({
title
:
Yup
.
string
()
.
required
(
'
제목을 입력해주세요.
'
),
...
...
@@ -76,34 +53,20 @@ function Write({ match }) {
.
required
(
'
내용을 입력해주세요.
'
),
})}
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
if
(
!
match
.
params
.
id
)
{
axios
({
method
:
'
post
'
,
url
:
'
/writes
'
,
data
:
values
,
}).
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
공지 등록이 완료되었습니다.
"
)
setState
(
true
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
else
{
axios
({
method
:
'
put
'
,
url
:
'
/writes/${id}
'
,
data
:
values
,
})
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
공지 수정이 완료되었습니다.
"
)
setState
(
true
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
console
.
log
(
values
)
axios
({
method
:
'
post
'
,
url
:
'
/writes
'
,
data
:
values
,
}).
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
공지 등록이 완료되었습니다.
"
)
setState
(
true
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
setTimeout
(()
=>
{
setSubmitting
(
false
);
},
400
);
// finish the cycle in handler
...
...
@@ -124,13 +87,12 @@ function Write({ match }) {
{...
getFieldProps
(
'
title
'
)}
placeholder
=
"
제목
"
/>
<
/div
>
{
console
.
log
(
revision
.
title
)}
<
div
className
=
"
form-group
"
>
<
div
className
=
{
touched
.
name
&&
errors
.
name
?
"
text-danger
"
:
""
}
>
내용
<
/div
>
<
Field
as
=
"
textarea
"
rows
=
{
8
}
style
=
{{
"
min-width
"
:
"
100%
"
}}
{...
getFieldProps
(
'
content
'
)}
/
>
<
/div
>
<
Button
className
=
"
mb-2
"
variant
=
"
dark
"
type
=
"
submit
"
disabled
=
{
isSubmitting
}
>
{
match
.
params
.
id
?
"
공지 수정
"
:
"
공지 등록
"
}
<
/Button
>
<
Button
className
=
"
mb-2
"
variant
=
"
dark
"
type
=
"
submit
"
disabled
=
{
isSubmitting
}
>
공지
등록
<
/Button
>
<
/form
>
)}
<
/Formik
>
...
...
@@ -141,4 +103,4 @@ function Write({ match }) {
)
}
export
default
Write
export
default
Write
\ No newline at end of file
server/client/src/index.js
View file @
7de8fc28
...
...
@@ -17,6 +17,7 @@ import Check from './Pages/CheckPage';
import
Notice
from
'
./Pages/NoticePage
'
;
import
ACheck
from
'
./Pages/ACheckPage
'
;
import
Write
from
'
./Pages/WritePage
'
;
import
Modify
from
'
./Pages/ModifyPage
'
;
axios
.
defaults
.
validateStatus
=
function
(
status
)
{
return
status
<
500
;
// default
...
...
@@ -33,7 +34,7 @@ ReactDOM.render(
<
Route
path
=
"
/change
"
component
=
{
Change
}
/
>
<
Route
path
=
"
/apply/:id
"
component
=
{
Apply
}
/
>
<
Route
path
=
"
/check/:id
"
component
=
{
Check
}
/
>
<
Route
path
=
"
/
write/revise
/:id
"
component
=
{
Write
}
/
>
<
Route
path
=
"
/
modify
/:id
"
component
=
{
Modify
}
/
>
<
Route
path
=
"
/write
"
component
=
{
Write
}
/
>
<
Route
path
=
"
/notice
"
component
=
{
Notice
}
/
>
<
Route
path
=
"
/acheck/:id
"
component
=
{
ACheck
}
/
>
...
...
server/routes/login.js
View file @
7de8fc28
...
...
@@ -2,7 +2,6 @@ const express = require('express');
const
User
=
require
(
'
../schemas/user
'
);
const
bcrypt
=
require
(
"
bcrypt
"
);
const
jwt
=
require
(
'
jsonwebtoken
'
);
const
user
=
require
(
'
../schemas/user
'
);
const
router
=
express
.
Router
();
...
...
@@ -66,4 +65,5 @@ router.post('/find', function (req, res, next) {
return
res
.
status
(
404
).
json
({
error
:
'
질문을 다시 선택해주세요.
'
});
})
});
module
.
exports
=
router
;
\ No newline at end of file
server/routes/notices.js
View file @
7de8fc28
...
...
@@ -18,7 +18,6 @@ router.get('/', function (req, res, next) {
router
.
get
(
'
/:id
'
,
function
(
req
,
res
,
next
)
{
Notice
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
notice
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
console
.
log
(
"
FindOne
"
,
notice
)
res
.
status
(
201
).
json
(
notice
);
})
});
...
...
server/routes/reserves.js
View file @
7de8fc28
const
express
=
require
(
'
express
'
);
const
User
=
require
(
'
../schemas/user
'
);
const
Reserve
=
require
(
'
../schemas/reserve
'
);
const
{
verifyToken
}
=
require
(
'
./middlewares
'
);
...
...
server/routes/users.js
View file @
7de8fc28
...
...
@@ -44,10 +44,11 @@ router.get('/:_id', verifyToken, function (req, res, next) {
router
.
get
(
'
/admin/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/admin get req.params
'
,
req
.
params
)
User
.
findOne
({
_id
:
req
.
params
.
_id
},
'
role
'
,
function
(
err
,
user
)
{
User
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
user
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
user
.
role
==
'
admin
'
)
{
next
();
if
(
user
.
role
===
'
admin
'
)
{
res
.
status
(
201
).
json
(
user
);
// next();
}
else
return
res
.
status
(
404
).
json
({
error
:
'
권한이 없습니다.
'
})
})
...
...
Prev
1
2
Next
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