mirror of
https://github.com/retspen/webvirtcloud
synced 2025-01-23 21:55:20 +00:00
fix profile/sshkeys form. empty public keys broke the page
This commit is contained in:
parent
fdf383a647
commit
f2e1273f85
2 changed files with 9 additions and 6 deletions
|
@ -95,20 +95,20 @@
|
|||
{% endif %}
|
||||
<form class="form-horizontal" method="post" action="" role="form">{% csrf_token %}
|
||||
<div class="form-group bridge_name_form_group_dhcp">
|
||||
<label class="col-sm-2 control-label">{% trans "Retry" %}</label>
|
||||
<label class="col-sm-2 control-label">{% trans "Key name" %}</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" name="keyname" placeholder="{% trans "Enter Name" %}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group bridge_name_form_group_dhcp">
|
||||
<label class="col-sm-2 control-label">{% trans "Retry" %}</label>
|
||||
<label class="col-sm-2 control-label">{% trans "Public key" %}</label>
|
||||
<div class="col-sm-8">
|
||||
<textarea name="keypublic" class="form-control" rows="6" placeholder="{% trans "Enter Public Key" %}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-primary">{% trans "Create" %}</button>
|
||||
<button type="submit" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -7,6 +7,9 @@ register = template.Library()
|
|||
|
||||
@register.simple_tag
|
||||
def ssh_to_fingerprint(line):
|
||||
key = base64.b64decode(line.strip().split()[1].encode('ascii'))
|
||||
fp_plain = hashlib.md5(key).hexdigest()
|
||||
return ':'.join(a + b for a, b in zip(fp_plain[::2], fp_plain[1::2]))
|
||||
try:
|
||||
key = base64.b64decode(line.strip().split()[1].encode('ascii'))
|
||||
fp_plain = hashlib.md5(key).hexdigest()
|
||||
return ':'.join(a + b for a, b in zip(fp_plain[::2], fp_plain[1::2]))
|
||||
except Exception:
|
||||
return 'Invalid key'
|
||||
|
|
Loading…
Reference in a new issue