Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-08-21 21:43:18 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2afc687cfc2232bcb172830db032728ddc1de29a
2afc687c
1 parent
d96ca1f5
feat. validate doctor's license api
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
server/src/api/manage/index.js
server/src/api/manage/manage.ctrl.js
server/src/api/manage/index.js
View file @
2afc687
...
...
@@ -35,5 +35,13 @@ manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq);
*/
manage
.
post
(
'/doctor/reject'
,
manageCtrl
.
rejectDoctorRegReq
);
/**
* 의사 요청을 한 회원의 자격 번호가 유효한지 검증한다
* reqeust parameter : doctor License
* url : http://localhost:4000/api/manage/doctor/validate
* return : result true or false
*/
manage
.
post
(
'/doctor/validate'
,
manageCtrl
.
validateDoctorLicense
);
module
.
exports
=
manage
;
\ No newline at end of file
...
...
server/src/api/manage/manage.ctrl.js
View file @
2afc687
...
...
@@ -264,3 +264,33 @@ exports.acceptDoctorRegReq = async ctx => {
}
};
/**
* 회원가입을 요청한 의사의 유효한 자격 번호인지를 검증한다.
* @param {*} ctx
* @returns
*/
exports
.
validateDoctorLicense
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
// eslint-disable-next-line no-undef
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
user
.
userTypeCd
!==
'MANAGER'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
const
{
doctorLicense
}
=
ctx
.
request
.
body
;
const
doctorInfo
=
await
DoctorInfo
.
find
({
'info.doctorLicense'
:
doctorLicense
});
ctx
.
status
=
200
;
ctx
.
body
=
{
result
:
doctorInfo
.
length
>
1
?
false
:
true
,
};
};
...
...
Please
register
or
login
to post a comment