From b8a8c3ebf3bec6ebbab19a02c92f8d5d775ad53e Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Tue, 23 Feb 2016 14:15:55 +0800 Subject: [PATCH 1/3] feat(juser/views.py;func:down_key): delete the private key when user download it issue:62 --- juser/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/juser/views.py b/juser/views.py index 41baa7536..1b85019be 100644 --- a/juser/views.py +++ b/juser/views.py @@ -466,6 +466,7 @@ def down_key(request): f.close() response = HttpResponse(data, content_type='application/octet-stream') response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file) + os.unlink(private_key_file) # delete it return response return HttpResponse('No Key File. Contact Admin.') From a037108cf373eb2195a92cb51ecfb87e017b873b Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Tue, 23 Feb 2016 14:23:07 +0800 Subject: [PATCH 2/3] refactor: double meaning --- juser/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juser/views.py b/juser/views.py index 1b85019be..64535f3fe 100644 --- a/juser/views.py +++ b/juser/views.py @@ -466,7 +466,7 @@ def down_key(request): f.close() response = HttpResponse(data, content_type='application/octet-stream') response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file) - os.unlink(private_key_file) # delete it + os.unlink(private_key_file) return response return HttpResponse('No Key File. Contact Admin.') From 27be35ae7701c9b3c68175537c68497d6aa5d482 Mon Sep 17 00:00:00 2001 From: liuzheng712 Date: Thu, 25 Feb 2016 13:04:09 +0800 Subject: [PATCH 3/3] fix(user_list.html & juser/views.py): only for user delete sshkey when downloaded, add generate butt https://github.com/jumpserver/jumpserver/issues/62 --- juser/views.py | 4 ++-- templates/juser/user_list.html | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/juser/views.py b/juser/views.py index 64535f3fe..a5978c80d 100644 --- a/juser/views.py +++ b/juser/views.py @@ -453,7 +453,6 @@ def down_key(request): uuid_r = request.GET.get('uuid', '') else: uuid_r = request.user.uuid - if uuid_r: user = get_object(User, uuid=uuid_r) if user: @@ -466,7 +465,8 @@ def down_key(request): f.close() response = HttpResponse(data, content_type='application/octet-stream') response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file) - os.unlink(private_key_file) + if request.user.role == 'CU': + os.unlink(private_key_file) return response return HttpResponse('No Key File. Contact Admin.') diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index f17fb9e03..7968e889e 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -70,7 +70,7 @@ {% if user.username|key_exist %} 下载 {% else %} - NoKey + NoKey GenOne? {% endif %} @@ -150,5 +150,13 @@ }); $('.shiftCheckbox').shiftcheckbox(); }); +function genSSH(username, url) { + if (confirm('Are you sure to gen a sshkey for user ' + username)) { + $.get(url, function (data) { + alert(data); + location.reload() + }) + } +} {% endblock %} \ No newline at end of file