pull/26/head
ibuler 9 years ago
parent cd798daf0a
commit cb12b83e47

@ -237,7 +237,7 @@ def key_exist(username):
"""
ssh key is exist or not
"""
if os.path.isfile(os.path.join(KEY_DIR, 'user', username)):
if os.path.isfile(os.path.join(KEY_DIR, 'user', username+'pem')):
return True
else:
return False

@ -458,15 +458,13 @@ def regen_ssh_key(request):
@require_role(role='user')
def down_key(request):
user_id = ''
if is_role_request(request, 'super'):
user_id = request.GET.get('id')
if is_role_request(request, 'user'):
user_id = request.user.id
uuid_r = request.GET.get('uuid', '')
else:
uuid_r = request.user.uuid
if user_id:
user = get_object(User, id=user_id)
if uuid_r:
user = get_object(User, uuid=uuid_r)
if user:
username = user.username
private_key_file = os.path.join(KEY_DIR, 'user', username)

@ -68,7 +68,7 @@
<td class="text-center">{{ user.is_active | bool2str }}</td>
<td class="text-center">
{% if user.username|key_exist %}
<a href="/juser/down_key/?id={{ user.id }}" >下载</a>
<a href="/juser/down_key/?uuid={{ user.uuid }}" >下载</a>
{% else %}
<span style="color: #586b7d">下载</span>
{% endif %}

Loading…
Cancel
Save