박권수

Merge branch 'server' into web

...@@ -29,12 +29,18 @@ exports.register = async(ctx) => { ...@@ -29,12 +29,18 @@ exports.register = async(ctx) => {
29 const result = schema.validate(ctx.request.body); 29 const result = schema.validate(ctx.request.body);
30 if(result.error || password !== passwordCheck) { 30 if(result.error || password !== passwordCheck) {
31 ctx.status = 400; 31 ctx.status = 400;
32 + ctx.body = {
33 + error : '회원가입 양식이 잘못되었습니다.',
34 + };
32 return; 35 return;
33 } 36 }
34 37
35 const existUser = await User.findByUserId(userId); 38 const existUser = await User.findByUserId(userId);
36 if(existUser) { 39 if(existUser) {
37 ctx.status = 409; 40 ctx.status = 409;
41 + ctx.body = {
42 + error : '이미 존재하는 회원입니다.',
43 + };
38 return; 44 return;
39 } 45 }
40 46
...@@ -78,13 +84,33 @@ exports.doctorRegister = async ctx => { ...@@ -78,13 +84,33 @@ exports.doctorRegister = async ctx => {
78 const result = schema.validate(ctx.request.body); 84 const result = schema.validate(ctx.request.body);
79 if(result.error || password !== passwordCheck) { 85 if(result.error || password !== passwordCheck) {
80 ctx.status = 400; 86 ctx.status = 400;
87 + ctx.body = {
88 + error : '회원가입 양식이 잘못되었습니다.',
89 + };
81 return; 90 return;
82 } 91 }
83 92
84 const existUser = await User.findByUserId(userId); 93 const existUser = await User.findByUserId(userId);
85 - const existDoctorInfo = await DoctorInfo.findByDoctorId(userId); 94 + if(existUser) {
86 - if(existUser || existDoctorInfo) {
87 ctx.status = 409; 95 ctx.status = 409;
96 + ctx.body = {
97 + error : '이미 존재하는 회원입니다.',
98 + };
99 + return;
100 + }
101 +
102 + const existDoctorInfo = await DoctorInfo.findByDoctorId(userId);
103 + if(existDoctorInfo.useYn === 'W') {
104 + ctx.status = 401;
105 + ctx.body = {
106 + error : '가입 승인 대기중인 회원입니다.',
107 + };
108 + return;
109 + } else if(existDoctorInfo.useYn === 'N') {
110 + ctx.status = 401;
111 + ctx.body = {
112 + error : '가입이 거절된 회원입니다.',
113 + };
88 return; 114 return;
89 } 115 }
90 116
...@@ -121,23 +147,35 @@ exports.login = async(ctx) => { ...@@ -121,23 +147,35 @@ exports.login = async(ctx) => {
121 const result = schema.validate(ctx.request.body); 147 const result = schema.validate(ctx.request.body);
122 if(result.error) { 148 if(result.error) {
123 ctx.status = 400; 149 ctx.status = 400;
150 + ctx.body = {
151 + error : '로그인 양식이 잘못되었습니다.',
152 + };
124 return; 153 return;
125 } 154 }
126 155
127 const user = await User.findByUserId(userId); 156 const user = await User.findByUserId(userId);
128 if(!user || !user.userTypeCd) { 157 if(!user || !user.userTypeCd) {
129 ctx.stauts = 401; 158 ctx.stauts = 401;
159 + ctx.body = {
160 + error : '존재하지 않는 회원입니다.',
161 + };
130 return; 162 return;
131 } 163 }
132 164
133 const isPasswordTrue = await user.checkPassword(password); 165 const isPasswordTrue = await user.checkPassword(password);
134 if(!isPasswordTrue) { 166 if(!isPasswordTrue) {
135 ctx.status = 401; 167 ctx.status = 401;
168 + ctx.body = {
169 + error : '비밀번호가 틀렸습니다.',
170 + };
136 return; 171 return;
137 } 172 }
138 173
139 if(user.useYn !== 'Y') { 174 if(user.useYn !== 'Y') {
140 ctx.status = 403; 175 ctx.status = 403;
176 + ctx.body = {
177 + error : '가입 대기중이거나 탈퇴한 회원입니다.',
178 + };
141 return; 179 return;
142 } 180 }
143 181
......
...@@ -98,7 +98,7 @@ exports.getDoctorRegReqDetail = async ctx => { ...@@ -98,7 +98,7 @@ exports.getDoctorRegReqDetail = async ctx => {
98 ctx.status = 400; 98 ctx.status = 400;
99 ctx.body = { 99 ctx.body = {
100 error : '이미 의사 인증이 완료된 회원입니다.' 100 error : '이미 의사 인증이 완료된 회원입니다.'
101 - };1 101 + };
102 return; 102 return;
103 } else if(doctorInfo.useYn === 'N') { 103 } else if(doctorInfo.useYn === 'N') {
104 ctx.status = 400; 104 ctx.status = 400;
...@@ -118,7 +118,6 @@ exports.getDoctorRegReqDetail = async ctx => { ...@@ -118,7 +118,6 @@ exports.getDoctorRegReqDetail = async ctx => {
118 ctx.body = { 118 ctx.body = {
119 error : '알 수 없는 에러가 발생했습니다.', 119 error : '알 수 없는 에러가 발생했습니다.',
120 }; 120 };
121 - console.log(e);
122 } 121 }
123 }; 122 };
124 123
...@@ -172,8 +171,15 @@ exports.acceptDoctorRegReq = async ctx => { ...@@ -172,8 +171,15 @@ exports.acceptDoctorRegReq = async ctx => {
172 return; 171 return;
173 } 172 }
174 173
174 + const doctorInfo = await DoctorInfo.findOne({
175 + doctorId,
176 + useYn : 'W',
177 + });
178 +
175 doctor.setUseYn('Y'); 179 doctor.setUseYn('Y');
176 doctor.save(); 180 doctor.save();
181 + doctorInfo.setUseYn('Y');
182 + doctorInfo.save();
177 183
178 ctx.status = 200; 184 ctx.status = 200;
179 185
...@@ -236,8 +242,16 @@ exports.acceptDoctorRegReq = async ctx => { ...@@ -236,8 +242,16 @@ exports.acceptDoctorRegReq = async ctx => {
236 return; 242 return;
237 } 243 }
238 244
245 +
246 + const doctorInfo = await DoctorInfo.findOne({
247 + doctorId,
248 + useYn : 'W',
249 + });
250 +
239 doctor.setUseYn('N'); 251 doctor.setUseYn('N');
240 doctor.save(); 252 doctor.save();
253 + doctorInfo.setUseYn('N');
254 + doctorInfo.save();
241 255
242 ctx.status = 200; 256 ctx.status = 200;
243 257
......