Showing
3 changed files
with
58 additions
and
60 deletions
... | @@ -10,13 +10,13 @@ from ..models import File, GroupUser | ... | @@ -10,13 +10,13 @@ from ..models import File, GroupUser |
10 | def list_item(request): | 10 | def list_item(request): |
11 | # Check Login | 11 | # Check Login |
12 | if request.user_id is None: | 12 | if request.user_id is None: |
13 | - return {'result': False, 'error': '권한이 없습니다.'} | 13 | + return {'result': False, 'error': '로그인을 해주세요.'} |
14 | 14 | ||
15 | # Validate | 15 | # Validate |
16 | if request.GET.get('is_public') != 'true' \ | 16 | if request.GET.get('is_public') != 'true' \ |
17 | and request.GET.get('is_starred') != 'true' \ | 17 | and request.GET.get('is_starred') != 'true' \ |
18 | and request.GET.get('is_trashed') != 'true': | 18 | and request.GET.get('is_trashed') != 'true': |
19 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 19 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
20 | 20 | ||
21 | # Query Files | 21 | # Query Files |
22 | files = None | 22 | files = None |
... | @@ -27,7 +27,7 @@ def list_item(request): | ... | @@ -27,7 +27,7 @@ def list_item(request): |
27 | elif request.GET.get('is_trashed') == 'true': | 27 | elif request.GET.get('is_trashed') == 'true': |
28 | files = File.objects.filter(owner_user_id=request.user_id, is_trashed=1, deleted_at__isnull=True) | 28 | files = File.objects.filter(owner_user_id=request.user_id, is_trashed=1, deleted_at__isnull=True) |
29 | 29 | ||
30 | - # Structure | 30 | + # Serialize |
31 | data = [] | 31 | data = [] |
32 | for file in files: | 32 | for file in files: |
33 | data.append({ | 33 | data.append({ |
... | @@ -48,22 +48,22 @@ def list_item(request): | ... | @@ -48,22 +48,22 @@ def list_item(request): |
48 | def create(request): | 48 | def create(request): |
49 | # Check Login | 49 | # Check Login |
50 | if request.user_id is None: | 50 | if request.user_id is None: |
51 | - return {'result': False, 'error': '권한이 없습니다.'} | 51 | + return {'result': False, 'error': '로그인을 해주세요.'} |
52 | 52 | ||
53 | # Load | 53 | # Load |
54 | try: | 54 | try: |
55 | received = json.loads(request.body.decode('utf-8')) | 55 | received = json.loads(request.body.decode('utf-8')) |
56 | except json.decoder.JSONDecodeError: | 56 | except json.decoder.JSONDecodeError: |
57 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 57 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
58 | 58 | ||
59 | # Validate | 59 | # Validate |
60 | if 'parent_id' not in received \ | 60 | if 'parent_id' not in received \ |
61 | or 'type' not in received \ | 61 | or 'type' not in received \ |
62 | or 'name' not in received: | 62 | or 'name' not in received: |
63 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 63 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
64 | if (received['type'] != 'folder' and received['type'] != 'file') \ | 64 | if (received['type'] != 'folder' and received['type'] != 'file') \ |
65 | or received['name'] == '': | 65 | or received['name'] == '': |
66 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 66 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
67 | 67 | ||
68 | # Get Parent | 68 | # Get Parent |
69 | parent = File.objects.filter(id=received['parent_id'], is_trashed=0, deleted_at__isnull=True) | 69 | parent = File.objects.filter(id=received['parent_id'], is_trashed=0, deleted_at__isnull=True) |
... | @@ -109,7 +109,7 @@ def create(request): | ... | @@ -109,7 +109,7 @@ def create(request): |
109 | def empty_trash(request): | 109 | def empty_trash(request): |
110 | # Check Login | 110 | # Check Login |
111 | if request.user_id is None: | 111 | if request.user_id is None: |
112 | - return {'result': False, 'error': '권한이 없습니다.'} | 112 | + return {'result': False, 'error': '로그인을 해주세요.'} |
113 | 113 | ||
114 | # Query Files | 114 | # Query Files |
115 | files = File.objects.filter(owner_user_id=request.user_id, is_trashed=1, deleted_at__isnull=True) | 115 | files = File.objects.filter(owner_user_id=request.user_id, is_trashed=1, deleted_at__isnull=True) |
... | @@ -143,7 +143,7 @@ def empty_trash(request): | ... | @@ -143,7 +143,7 @@ def empty_trash(request): |
143 | def find_item(request, file_id): | 143 | def find_item(request, file_id): |
144 | # Check Login | 144 | # Check Login |
145 | if request.user_id is None: | 145 | if request.user_id is None: |
146 | - return {'result': False, 'error': '권한이 없습니다.'} | 146 | + return {'result': False, 'error': '로그인을 해주세요.'} |
147 | 147 | ||
148 | # Query | 148 | # Query |
149 | file = File.objects.filter(id=file_id, deleted_at__isnull=True) | 149 | file = File.objects.filter(id=file_id, deleted_at__isnull=True) |
... | @@ -183,7 +183,6 @@ def find_item(request, file_id): | ... | @@ -183,7 +183,6 @@ def find_item(request, file_id): |
183 | data = { | 183 | data = { |
184 | 'id': file[0].id, | 184 | 'id': file[0].id, |
185 | 'parent_id': file[0].parent_id, | 185 | 'parent_id': file[0].parent_id, |
186 | - 'uploader_id': file[0].uploader_id, | ||
187 | 'name': file[0].name, | 186 | 'name': file[0].name, |
188 | 'size': file[0].size, | 187 | 'size': file[0].size, |
189 | 'is_public': file[0].is_public, | 188 | 'is_public': file[0].is_public, |
... | @@ -219,13 +218,13 @@ def find_item(request, file_id): | ... | @@ -219,13 +218,13 @@ def find_item(request, file_id): |
219 | def update_item(request, file_id): | 218 | def update_item(request, file_id): |
220 | # Check Login | 219 | # Check Login |
221 | if request.user_id is None: | 220 | if request.user_id is None: |
222 | - return {'result': False, 'error': '권한이 없습니다.'} | 221 | + return {'result': False, 'error': '로그인을 해주세요.'} |
223 | 222 | ||
224 | # Load | 223 | # Load |
225 | try: | 224 | try: |
226 | received = json.loads(request.body.decode('utf-8')) | 225 | received = json.loads(request.body.decode('utf-8')) |
227 | except json.decoder.JSONDecodeError: | 226 | except json.decoder.JSONDecodeError: |
228 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 227 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
229 | 228 | ||
230 | # Validate | 229 | # Validate |
231 | if 'name' not in received \ | 230 | if 'name' not in received \ |
... | @@ -233,7 +232,7 @@ def update_item(request, file_id): | ... | @@ -233,7 +232,7 @@ def update_item(request, file_id): |
233 | and 'is_public' not in received \ | 232 | and 'is_public' not in received \ |
234 | and 'is_starred' not in received \ | 233 | and 'is_starred' not in received \ |
235 | and 'is_trashed' not in received: | 234 | and 'is_trashed' not in received: |
236 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 235 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
237 | 236 | ||
238 | # Query | 237 | # Query |
239 | file = File.objects.filter(id=file_id, deleted_at__isnull=True) | 238 | file = File.objects.filter(id=file_id, deleted_at__isnull=True) |
... | @@ -292,7 +291,7 @@ def update_item(request, file_id): | ... | @@ -292,7 +291,7 @@ def update_item(request, file_id): |
292 | def copy(request, file_id): | 291 | def copy(request, file_id): |
293 | # Check Login | 292 | # Check Login |
294 | if request.user_id is None: | 293 | if request.user_id is None: |
295 | - return {'result': False, 'error': '권한이 없습니다.'} | 294 | + return {'result': False, 'error': '로그인을 해주세요.'} |
296 | 295 | ||
297 | # Get File | 296 | # Get File |
298 | file = File.objects.filter(id=file_id, type='file', is_trashed=0, deleted_at__isnull=True) | 297 | file = File.objects.filter(id=file_id, type='file', is_trashed=0, deleted_at__isnull=True) | ... | ... |
... | @@ -9,17 +9,17 @@ from ..models import File, Group, GroupUser, User | ... | @@ -9,17 +9,17 @@ from ..models import File, Group, GroupUser, User |
9 | def create(request): | 9 | def create(request): |
10 | # Check Login | 10 | # Check Login |
11 | if request.user_id is None: | 11 | if request.user_id is None: |
12 | - return {'result': False, 'error': '권한이 없습니다.'} | 12 | + return {'result': False, 'error': '로그인을 해주세요.'} |
13 | 13 | ||
14 | # Load | 14 | # Load |
15 | try: | 15 | try: |
16 | received = json.loads(request.body.decode('utf-8')) | 16 | received = json.loads(request.body.decode('utf-8')) |
17 | except json.decoder.JSONDecodeError: | 17 | except json.decoder.JSONDecodeError: |
18 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 18 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
19 | 19 | ||
20 | # Validate | 20 | # Validate |
21 | if 'name' not in received or received['name'] == '': | 21 | if 'name' not in received or received['name'] == '': |
22 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 22 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
23 | 23 | ||
24 | # Create | 24 | # Create |
25 | root_folder = uuid.uuid4() | 25 | root_folder = uuid.uuid4() |
... | @@ -45,25 +45,24 @@ def create(request): | ... | @@ -45,25 +45,24 @@ def create(request): |
45 | created_at=timezone.now() | 45 | created_at=timezone.now() |
46 | ) | 46 | ) |
47 | 47 | ||
48 | - return {'result': True, 'group_id': group.id} | 48 | + return {'result': True} |
49 | 49 | ||
50 | 50 | ||
51 | # 그룹 초대장 조회 | 51 | # 그룹 초대장 조회 |
52 | def find_invite(request, invite_code): | 52 | def find_invite(request, invite_code): |
53 | # Check Login | 53 | # Check Login |
54 | if request.user_id is None: | 54 | if request.user_id is None: |
55 | - return {'result': False, 'error': '권한이 없습니다.'} | 55 | + return {'result': False, 'error': '로그인을 해주세요.'} |
56 | 56 | ||
57 | # Query | 57 | # Query |
58 | group = Group.objects.filter(invite_code=invite_code) | 58 | group = Group.objects.filter(invite_code=invite_code) |
59 | 59 | ||
60 | # Check Exists | 60 | # Check Exists |
61 | if len(group) == 0: | 61 | if len(group) == 0: |
62 | - return {'result': False, 'error': '존재하지 않는 초대장입니다.'} | 62 | + return {'result': False, 'error': '잘못된 초대코드입니다.'} |
63 | 63 | ||
64 | - # Structure | 64 | + # Serialize |
65 | data = { | 65 | data = { |
66 | - 'id': group[0].id, | ||
67 | 'name': group[0].name | 66 | 'name': group[0].name |
68 | } | 67 | } |
69 | 68 | ||
... | @@ -81,14 +80,14 @@ def find_invite(request, invite_code): | ... | @@ -81,14 +80,14 @@ def find_invite(request, invite_code): |
81 | def use_invite(request, invite_code): | 80 | def use_invite(request, invite_code): |
82 | # Check Login | 81 | # Check Login |
83 | if request.user_id is None: | 82 | if request.user_id is None: |
84 | - return {'result': False, 'error': '권한이 없습니다.'} | 83 | + return {'result': False, 'error': '로그인을 해주세요.'} |
85 | 84 | ||
86 | # Query | 85 | # Query |
87 | group = Group.objects.filter(invite_code=invite_code) | 86 | group = Group.objects.filter(invite_code=invite_code) |
88 | 87 | ||
89 | # Check Exists | 88 | # Check Exists |
90 | if len(group) == 0: | 89 | if len(group) == 0: |
91 | - return {'result': False, 'error': '존재하지 않는 초대장입니다.'} | 90 | + return {'result': False, 'error': '잘못된 초대코드입니다.'} |
92 | 91 | ||
93 | # Check Joined | 92 | # Check Joined |
94 | joined = GroupUser.objects.filter(group_id=group[0].id, user_id=request.user_id) | 93 | joined = GroupUser.objects.filter(group_id=group[0].id, user_id=request.user_id) |
... | @@ -109,17 +108,16 @@ def use_invite(request, invite_code): | ... | @@ -109,17 +108,16 @@ def use_invite(request, invite_code): |
109 | def list_me(request): | 108 | def list_me(request): |
110 | # Check Login | 109 | # Check Login |
111 | if request.user_id is None: | 110 | if request.user_id is None: |
112 | - return {'result': False, 'error': '권한이 없습니다.'} | 111 | + return {'result': False, 'error': '로그인을 해주세요.'} |
113 | 112 | ||
114 | # Query | 113 | # Query |
115 | joined = GroupUser.objects.filter(user_id=request.user_id).values_list('group_id', flat=True) | 114 | joined = GroupUser.objects.filter(user_id=request.user_id).values_list('group_id', flat=True) |
116 | groups = Group.objects.filter(id__in=joined) | 115 | groups = Group.objects.filter(id__in=joined) |
117 | 116 | ||
118 | - # Structure | 117 | + # Serialize |
119 | data = [] | 118 | data = [] |
120 | for group in groups: | 119 | for group in groups: |
121 | data.append({ | 120 | data.append({ |
122 | - 'id': group.id, | ||
123 | 'name': group.name, | 121 | 'name': group.name, |
124 | 'root_folder': group.root_folder, | 122 | 'root_folder': group.root_folder, |
125 | }) | 123 | }) |
... | @@ -131,23 +129,22 @@ def list_me(request): | ... | @@ -131,23 +129,22 @@ def list_me(request): |
131 | def find_item(request, group_id): | 129 | def find_item(request, group_id): |
132 | # Check Login | 130 | # Check Login |
133 | if request.user_id is None: | 131 | if request.user_id is None: |
134 | - return {'result': False, 'error': '권한이 없습니다.'} | 132 | + return {'result': False, 'error': '로그인을 해주세요.'} |
135 | 133 | ||
136 | # Check Joined | 134 | # Check Joined |
137 | joined = GroupUser.objects.filter(group_id=group_id, user_id=request.user_id) | 135 | joined = GroupUser.objects.filter(group_id=group_id, user_id=request.user_id) |
138 | if len(joined) == 0: | 136 | if len(joined) == 0: |
139 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 137 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
140 | 138 | ||
141 | # Query | 139 | # Query |
142 | group = Group.objects.filter(id=group_id) | 140 | group = Group.objects.filter(id=group_id) |
143 | 141 | ||
144 | # Check Exists | 142 | # Check Exists |
145 | if len(group) == 0: | 143 | if len(group) == 0: |
146 | - return {'result': False, 'error': '존재하지 않는 그룹입니다.'} | 144 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
147 | 145 | ||
148 | - # Structure | 146 | + # Serialize |
149 | data = { | 147 | data = { |
150 | - 'id': group[0].id, | ||
151 | 'name': group[0].name, | 148 | 'name': group[0].name, |
152 | 'root_folder': group[0].root_folder, | 149 | 'root_folder': group[0].root_folder, |
153 | } | 150 | } |
... | @@ -162,9 +159,9 @@ def find_item(request, group_id): | ... | @@ -162,9 +159,9 @@ def find_item(request, group_id): |
162 | 'id': user.id, | 159 | 'id': user.id, |
163 | 'name': user.name, | 160 | 'name': user.name, |
164 | }) | 161 | }) |
165 | - data['user'] = user_data | 162 | + data['id'] = group[0].id |
163 | + data['users'] = user_data | ||
166 | data['invite_code'] = group[0].invite_code | 164 | data['invite_code'] = group[0].invite_code |
167 | - data['created_at'] = group[0].created_at | ||
168 | data['is_owner'] = True | 165 | data['is_owner'] = True |
169 | 166 | ||
170 | return {'result': True, 'data': data} | 167 | return {'result': True, 'data': data} |
... | @@ -174,28 +171,28 @@ def find_item(request, group_id): | ... | @@ -174,28 +171,28 @@ def find_item(request, group_id): |
174 | def update_item(request, group_id): | 171 | def update_item(request, group_id): |
175 | # Check Login | 172 | # Check Login |
176 | if request.user_id is None: | 173 | if request.user_id is None: |
177 | - return {'result': False, 'error': '권한이 없습니다.'} | 174 | + return {'result': False, 'error': '로그인을 해주세요.'} |
178 | 175 | ||
179 | # Load | 176 | # Load |
180 | try: | 177 | try: |
181 | received = json.loads(request.body.decode('utf-8')) | 178 | received = json.loads(request.body.decode('utf-8')) |
182 | except json.decoder.JSONDecodeError: | 179 | except json.decoder.JSONDecodeError: |
183 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 180 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
184 | 181 | ||
185 | # Validate | 182 | # Validate |
186 | if 'name' not in received or received['name'] == '': | 183 | if 'name' not in received or received['name'] == '': |
187 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 184 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
188 | 185 | ||
189 | # Query | 186 | # Query |
190 | group = Group.objects.filter(id=group_id) | 187 | group = Group.objects.filter(id=group_id) |
191 | 188 | ||
192 | # Check Exists | 189 | # Check Exists |
193 | if len(group) == 0: | 190 | if len(group) == 0: |
194 | - return {'result': False, 'error': '존재하지 않는 그룹입니다.'} | 191 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
195 | 192 | ||
196 | # Check Owner | 193 | # Check Owner |
197 | if group[0].owner_id != request.user_id: | 194 | if group[0].owner_id != request.user_id: |
198 | - return {'result': False, 'error': '권한이 없습니다.'} | 195 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
199 | 196 | ||
200 | # Update | 197 | # Update |
201 | group[0].name = received['name'] | 198 | group[0].name = received['name'] |
... | @@ -208,18 +205,18 @@ def update_item(request, group_id): | ... | @@ -208,18 +205,18 @@ def update_item(request, group_id): |
208 | def delete_item(request, group_id): | 205 | def delete_item(request, group_id): |
209 | # Check Login | 206 | # Check Login |
210 | if request.user_id is None: | 207 | if request.user_id is None: |
211 | - return {'result': False, 'error': '권한이 없습니다.'} | 208 | + return {'result': False, 'error': '로그인을 해주세요.'} |
212 | 209 | ||
213 | # Query | 210 | # Query |
214 | group = Group.objects.filter(id=group_id) | 211 | group = Group.objects.filter(id=group_id) |
215 | 212 | ||
216 | # Check Exists | 213 | # Check Exists |
217 | if len(group) == 0: | 214 | if len(group) == 0: |
218 | - return {'result': False, 'error': '존재하지 않는 그룹입니다.'} | 215 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
219 | 216 | ||
220 | # Check Owner | 217 | # Check Owner |
221 | if group[0].owner_id != request.user_id: | 218 | if group[0].owner_id != request.user_id: |
222 | - return {'result': False, 'error': '권한이 없습니다.'} | 219 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
223 | 220 | ||
224 | # S3 Delete | 221 | # S3 Delete |
225 | del_list = File.objects.filter(owner_group_id=group_id).values_list('id', flat=True) | 222 | del_list = File.objects.filter(owner_group_id=group_id).values_list('id', flat=True) |
... | @@ -237,14 +234,14 @@ def delete_item(request, group_id): | ... | @@ -237,14 +234,14 @@ def delete_item(request, group_id): |
237 | def remove_user(request, group_id, user_id): | 234 | def remove_user(request, group_id, user_id): |
238 | # Check Login | 235 | # Check Login |
239 | if request.user_id is None: | 236 | if request.user_id is None: |
240 | - return {'result': False, 'error': '권한이 없습니다.'} | 237 | + return {'result': False, 'error': '로그인을 해주세요.'} |
241 | 238 | ||
242 | # Query | 239 | # Query |
243 | group = Group.objects.filter(id=group_id) | 240 | group = Group.objects.filter(id=group_id) |
244 | 241 | ||
245 | # Check Owner | 242 | # Check Owner |
246 | if group[0].owner_id != request.user_id: | 243 | if group[0].owner_id != request.user_id: |
247 | - return {'result': False, 'error': '권한이 없습니다.'} | 244 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
248 | 245 | ||
249 | # Check Me | 246 | # Check Me |
250 | if int(user_id) == request.user_id: | 247 | if int(user_id) == request.user_id: | ... | ... |
... | @@ -16,32 +16,34 @@ def create(request): | ... | @@ -16,32 +16,34 @@ def create(request): |
16 | try: | 16 | try: |
17 | received = json.loads(request.body.decode('utf-8')) | 17 | received = json.loads(request.body.decode('utf-8')) |
18 | except json.decoder.JSONDecodeError: | 18 | except json.decoder.JSONDecodeError: |
19 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 19 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
20 | 20 | ||
21 | # Validate | 21 | # Validate |
22 | if 'email' not in received \ | 22 | if 'email' not in received \ |
23 | or 'password' not in received \ | 23 | or 'password' not in received \ |
24 | or 'name' not in received: | 24 | or 'name' not in received: |
25 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 25 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
26 | 26 | ||
27 | # Validate Email | 27 | # Validate Email |
28 | try: | 28 | try: |
29 | validate_email(received['email']) | 29 | validate_email(received['email']) |
30 | except ValidationError: | 30 | except ValidationError: |
31 | - return {'result': False, 'error': '이메일 형식이 잘못되었습니다.'} | 31 | + return {'result': False, 'error': '이메일을 제대로 입력해주세요.'} |
32 | 32 | ||
33 | # Validate Password | 33 | # Validate Password |
34 | if len(received['password']) < 8: | 34 | if len(received['password']) < 8: |
35 | - return {'result': False, 'error': '비밀번호는 최소 8글자 입니다.'} | 35 | + return {'result': False, 'error': '비밀번호를 8자리 이상으로 입력해주세요.'} |
36 | 36 | ||
37 | # Validate Name | 37 | # Validate Name |
38 | if len(received['name']) > 50: | 38 | if len(received['name']) > 50: |
39 | return {'result': False, 'error': '이름은 최대 50글자 입니다.'} | 39 | return {'result': False, 'error': '이름은 최대 50글자 입니다.'} |
40 | + elif len(received['name']) == 0: | ||
41 | + return {'result': False, 'error': '이름을 제대로 입력해주세요.'} | ||
40 | 42 | ||
41 | # Check Duplicates | 43 | # Check Duplicates |
42 | is_exists = User.objects.filter(email=received['email']) | 44 | is_exists = User.objects.filter(email=received['email']) |
43 | if len(is_exists) > 0: | 45 | if len(is_exists) > 0: |
44 | - return {'result': False, 'error': '이미 사용중인 이메일 주소 입니다.'} | 46 | + return {'result': False, 'error': '이미 사용 중인 이메일입니다.'} |
45 | 47 | ||
46 | # Insert | 48 | # Insert |
47 | root_folder = uuid.uuid4() | 49 | root_folder = uuid.uuid4() |
... | @@ -70,21 +72,21 @@ def login(request): | ... | @@ -70,21 +72,21 @@ def login(request): |
70 | try: | 72 | try: |
71 | received = json.loads(request.body.decode('utf-8')) | 73 | received = json.loads(request.body.decode('utf-8')) |
72 | except json.decoder.JSONDecodeError: | 74 | except json.decoder.JSONDecodeError: |
73 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 75 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
74 | 76 | ||
75 | # Validate | 77 | # Validate |
76 | if 'email' not in received \ | 78 | if 'email' not in received \ |
77 | or 'password' not in received: | 79 | or 'password' not in received: |
78 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 80 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
79 | 81 | ||
80 | - # Select | 82 | + # Query |
81 | user = User.objects.filter(email=received['email']) | 83 | user = User.objects.filter(email=received['email']) |
82 | 84 | ||
83 | - # Not Exists | 85 | + # Check Exists |
84 | if len(user) != 1: | 86 | if len(user) != 1: |
85 | return {'result': False, 'error': '로그인에 실패하였습니다.'} | 87 | return {'result': False, 'error': '로그인에 실패하였습니다.'} |
86 | 88 | ||
87 | - # Check | 89 | + # Check Password |
88 | if check_password(received['password'], user[0].password) is False: | 90 | if check_password(received['password'], user[0].password) is False: |
89 | return {'result': False, 'error': '로그인에 실패하였습니다.'} | 91 | return {'result': False, 'error': '로그인에 실패하였습니다.'} |
90 | 92 | ||
... | @@ -99,7 +101,7 @@ def login(request): | ... | @@ -99,7 +101,7 @@ def login(request): |
99 | def find_me(request): | 101 | def find_me(request): |
100 | # Check Login | 102 | # Check Login |
101 | if request.user_id is None: | 103 | if request.user_id is None: |
102 | - return {'result': False, 'error': '권한이 없습니다.'} | 104 | + return {'result': False, 'error': '로그인을 해주세요.'} |
103 | 105 | ||
104 | # Query | 106 | # Query |
105 | user = User.objects.filter(id=request.user_id) | 107 | user = User.objects.filter(id=request.user_id) |
... | @@ -124,18 +126,18 @@ def find_me(request): | ... | @@ -124,18 +126,18 @@ def find_me(request): |
124 | def update_me(request): | 126 | def update_me(request): |
125 | # Check Login | 127 | # Check Login |
126 | if request.user_id is None: | 128 | if request.user_id is None: |
127 | - return {'result': False, 'error': '권한이 없습니다.'} | 129 | + return {'result': False, 'error': '로그인을 해주세요.'} |
128 | 130 | ||
129 | # Load | 131 | # Load |
130 | try: | 132 | try: |
131 | received = json.loads(request.body.decode('utf-8')) | 133 | received = json.loads(request.body.decode('utf-8')) |
132 | except json.decoder.JSONDecodeError: | 134 | except json.decoder.JSONDecodeError: |
133 | - return {'result': False, 'error': '입력이 잘못되었습니다.'} | 135 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
134 | 136 | ||
135 | # Validate | 137 | # Validate |
136 | if 'name' not in received \ | 138 | if 'name' not in received \ |
137 | and ('old_password' not in received and 'password' not in received): | 139 | and ('old_password' not in received and 'password' not in received): |
138 | - return {'result': False, 'error': '입력이 누락되었습니다.'} | 140 | + return {'result': False, 'error': '잘못된 요청입니다.'} |
139 | 141 | ||
140 | # Query | 142 | # Query |
141 | user = User.objects.filter(id=request.user_id) | 143 | user = User.objects.filter(id=request.user_id) |
... | @@ -151,9 +153,9 @@ def update_me(request): | ... | @@ -151,9 +153,9 @@ def update_me(request): |
151 | # Change Password | 153 | # Change Password |
152 | if 'old_password' in received and 'password' in received: | 154 | if 'old_password' in received and 'password' in received: |
153 | if check_password(received['old_password'], user[0].password) is False: | 155 | if check_password(received['old_password'], user[0].password) is False: |
154 | - return {'result': False, 'error': '이전 비밀번호가 잘못되었습니다.'} | 156 | + return {'result': False, 'error': '이전 비밀번호를 제대로 입력해주세요.'} |
155 | if len(received['password']) < 8: | 157 | if len(received['password']) < 8: |
156 | - return {'result': False, 'error': '비밀번호는 최소 8글자 입니다.'} | 158 | + return {'result': False, 'error': '비밀번호를 8자리 이상으로 입력해주세요.'} |
157 | user[0].password = make_password(received['password']) | 159 | user[0].password = make_password(received['password']) |
158 | 160 | ||
159 | # Save | 161 | # Save | ... | ... |
-
Please register or login to post a comment