1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 01:44:13 +00:00

update permission check when download file from history

This commit is contained in:
lian
2017-02-24 18:13:20 +08:00
parent 8a113bf1eb
commit f99e53680e

View File

@@ -1282,9 +1282,10 @@ def download_file(request, repo_id, obj_id):
if repo.encrypted and not seafile_api.is_password_set(repo_id, username): if repo.encrypted and not seafile_api.is_password_set(repo_id, username):
return HttpResponseRedirect(reverse('view_common_lib_dir', args=[repo_id, ''])) return HttpResponseRedirect(reverse('view_common_lib_dir', args=[repo_id, '']))
# Permission check and generate download link # only check the permissions at the repo level
path = request.GET.get('p', '') # to prevent file can not be downloaded on the history page
if check_folder_permission(request, repo_id, path): # if it has been renamed
if check_folder_permission(request, repo_id, '/'):
# Get a token to access file # Get a token to access file
token = seafile_api.get_fileserver_access_token(repo_id, obj_id, token = seafile_api.get_fileserver_access_token(repo_id, obj_id,
'download', username) 'download', username)
@@ -1293,11 +1294,11 @@ def download_file(request, repo_id, obj_id):
next = request.META.get('HTTP_REFERER', settings.SITE_ROOT) next = request.META.get('HTTP_REFERER', settings.SITE_ROOT)
return HttpResponseRedirect(next) return HttpResponseRedirect(next)
# send stats message path = request.GET.get('p', '')
send_file_access_msg(request, repo, path, 'web') send_file_access_msg(request, repo, path, 'web') # send stats message
file_name = os.path.basename(path.rstrip('/')) file_name = os.path.basename(path.rstrip('/'))
redirect_url = gen_file_get_url(token, file_name) redirect_url = gen_file_get_url(token, file_name) # generate download link
return HttpResponseRedirect(redirect_url) return HttpResponseRedirect(redirect_url)
########## text diff ########## text diff