mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 00:20:07 +00:00
[api2] Fix create dir shared item bug
This commit is contained in:
@@ -249,6 +249,10 @@ class DirSharedItemsEndpoint(APIView):
|
|||||||
if share_type == 'user':
|
if share_type == 'user':
|
||||||
share_to_users = request.DATA.getlist('username')
|
share_to_users = request.DATA.getlist('username')
|
||||||
for to_user in share_to_users:
|
for to_user in share_to_users:
|
||||||
|
if not is_valid_username(to_user):
|
||||||
|
return api_error(status.HTTP_400_BAD_REQUEST,
|
||||||
|
'Username must be a valid email address.')
|
||||||
|
|
||||||
if not check_user_share_quota(username, shared_repo, users=[to_user]):
|
if not check_user_share_quota(username, shared_repo, users=[to_user]):
|
||||||
return api_error(status.HTTP_403_FORBIDDEN,
|
return api_error(status.HTTP_403_FORBIDDEN,
|
||||||
'Failed to share: No enough quota.')
|
'Failed to share: No enough quota.')
|
||||||
|
@@ -68,6 +68,17 @@ class DirSharedItemsTest(BaseTestCase):
|
|||||||
assert len(json_resp['success']) == 2
|
assert len(json_resp['success']) == 2
|
||||||
assert json_resp['success'][0]['permission'] == 'r'
|
assert json_resp['success'][0]['permission'] == 'r'
|
||||||
|
|
||||||
|
def test_share_folder_to_invalid_email(self):
|
||||||
|
self.login_as(self.user)
|
||||||
|
|
||||||
|
resp = self.client.put(
|
||||||
|
'/api2/repos/%s/dir/shared_items/?p=%s' % (self.repo.id,
|
||||||
|
self.folder),
|
||||||
|
"share_type=user&username=abc",
|
||||||
|
'application/x-www-form-urlencoded',
|
||||||
|
)
|
||||||
|
self.assertEqual(400, resp.status_code)
|
||||||
|
|
||||||
def test_can_share_root_to_groups(self):
|
def test_can_share_root_to_groups(self):
|
||||||
self.login_as(self.user)
|
self.login_as(self.user)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user