Showing
2 changed files
with
38 additions
and
0 deletions
| ... | @@ -35,5 +35,13 @@ manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq); | ... | @@ -35,5 +35,13 @@ manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq); |
| 35 | */ | 35 | */ |
| 36 | manage.post('/doctor/reject', manageCtrl.rejectDoctorRegReq); | 36 | manage.post('/doctor/reject', manageCtrl.rejectDoctorRegReq); |
| 37 | 37 | ||
| 38 | +/** | ||
| 39 | + * 의사 요청을 한 회원의 자격 번호가 유효한지 검증한다 | ||
| 40 | + * reqeust parameter : doctor License | ||
| 41 | + * url : http://localhost:4000/api/manage/doctor/validate | ||
| 42 | + * return : result true or false | ||
| 43 | + */ | ||
| 44 | +manage.post('/doctor/validate', manageCtrl.validateDoctorLicense); | ||
| 45 | + | ||
| 38 | 46 | ||
| 39 | module.exports = manage; | 47 | module.exports = manage; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -264,3 +264,33 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -264,3 +264,33 @@ exports.acceptDoctorRegReq = async ctx => { |
| 264 | } | 264 | } |
| 265 | }; | 265 | }; |
| 266 | 266 | ||
| 267 | +/** | ||
| 268 | + * 회원가입을 요청한 의사의 유효한 자격 번호인지를 검증한다. | ||
| 269 | + * @param {*} ctx | ||
| 270 | + * @returns | ||
| 271 | + */ | ||
| 272 | +exports.validateDoctorLicense = async ctx => { | ||
| 273 | + const token = ctx.req.headers.authorization; | ||
| 274 | + if (!token || !token.length) { | ||
| 275 | + ctx.status = 401; | ||
| 276 | + return; | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + // eslint-disable-next-line no-undef | ||
| 280 | + const { userId } = jwt.verify(token, process.env.JWT_SECRET); | ||
| 281 | + const user = await User.findByUserId(userId); | ||
| 282 | + if(!user || user.userTypeCd !== 'MANAGER' || user.useYn !== 'Y') { | ||
| 283 | + ctx.status = 403; | ||
| 284 | + return; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + const { doctorLicense } = ctx.request.body; | ||
| 288 | + const doctorInfo = await DoctorInfo.find({ 'info.doctorLicense' : doctorLicense }); | ||
| 289 | + | ||
| 290 | + ctx.status = 200; | ||
| 291 | + ctx.body = { | ||
| 292 | + result : doctorInfo.length > 1 ? false : true, | ||
| 293 | + }; | ||
| 294 | + | ||
| 295 | +}; | ||
| 296 | + | ... | ... |
-
Please register or login to post a comment