From be374f5d7794b235de88edb818e3d535b5378048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Mon, 30 Sep 2019 01:38:23 +0200 Subject: [PATCH] fix functions delete/edit/... on different state --- certweb/pubkeys.py | 3 +- certweb/static/style.css | 2 +- certweb/templates/certificates/index.html | 60 +++++++++++------------ certweb/templates/pubkeys/index.html | 49 +++++++++--------- certweb/templates/pubkeys/update.html | 8 ++- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/certweb/pubkeys.py b/certweb/pubkeys.py index 85650de..64138db 100644 --- a/certweb/pubkeys.py +++ b/certweb/pubkeys.py @@ -69,7 +69,8 @@ def create(): print(fingerprint) ckfp = db.execute( - 'SELECT id, fingerprint, deleted FROM pubkeys WHERE fingerprint = ?', (fingerprint, ) + 'SELECT id, fingerprint, deleted FROM pubkeys' + ' WHERE fingerprint = ? AND user_id = ?', (fingerprint, g.user['id'] ) ).fetchone() diff --git a/certweb/static/style.css b/certweb/static/style.css index 83c4edf..e4978ac 100644 --- a/certweb/static/style.css +++ b/certweb/static/style.css @@ -29,4 +29,4 @@ nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; } .danger { color: #cc2f2e; } input.danger { color: #cc2f2e; } input[type=submit] { align-self: start; min-width: 10em; } -.key { color: #cc22ff; } +.key { border: 1px solid lightgray;} diff --git a/certweb/templates/certificates/index.html b/certweb/templates/certificates/index.html index 60451ce..c1ea139 100644 --- a/certweb/templates/certificates/index.html +++ b/certweb/templates/certificates/index.html @@ -8,7 +8,7 @@ Certificates {% endif %} {% endblock %} - {% if g.user %} + {% if g.user and pubkey['revoked'] == 0 %}
@@ -26,43 +26,43 @@ {% block content %} {% if g.user %} - {% for certificate in certificates %} - {% if certificate['deleted'] == 0 and pubkey['user_id'] == g.user['id'] %} + {% if ( certificate['deleted'] == 0 and pubkey['user_id'] == g.user['id'] ) or user['admin'] == 1 %}
-
-

Certificate ID: {{ certificate['key_id'] }}

- {% if certificate['revoked'] != 0 %} -
this certificate was manually revoked
+
+

+ Certificate ID: {{ certificate['key_id'] }} +

+ {% if certificate['revoked'] != 0 %} +
this certificate was manually revoked
+ {% endif %} +
+ {% if g.user['id'] == certificate['user_id'] %} + {% if certificate['revoked'] == 0 or certificate['valid'] == 0 %} + + + + {% else %} +
revoked
+ Delete + {% endif %} {% endif %} -
- {% if g.user['id'] == certificate['user_id'] %} - {% if certificate['revoked'] == 0 or certificate['valid'] == 0 %} -
- -
- {% else %} -
revoked
- Delete - {% endif %} - {% endif %}

- Serialnumber: {{ certificate['serial'] }}{% if certificate['c.revoked'] != 0 %} - revoked {% endif %} - Validity duration: {{ certificate['valid_from'].strftime('%Y-%m-%d %H:%M') }} - {{ certificate['valid_until'].strftime('%Y-%m-%d %H:%M') }} - Principals: {{ certificate['principals'] }} - Valid Client IP: {{ certificate['from_ip'] }} - Allowed Command: {{ certificate['commands'] }} - Capabilities: {{ certificate['capabilities'] }} - Internal DB-Id: {{ certificate['id'] }} - Deleted: {{ certificate['deleted'] }} + {% if user['admin'] == 1 %} +

owner: {{ pubkey['username']}}
+ {% endif %} + Serialnumber: {{ certificate['serial'] }}{% if certificate['c.revoked'] != 0 %} - revoked {% endif %} + Validity duration: {{ certificate['valid_from'].strftime('%Y-%m-%d %H:%M') }} - {{ certificate['valid_until'].strftime('%Y-%m-%d %H:%M') }} + Principals: {{ certificate['principals'] }} + Valid Client IP: {{ certificate['from_ip'] }} + Allowed Command: {{ certificate['commands'] }} + Capabilities: {{ certificate['capabilities'] }} + Internal DB-Id: {{ certificate['id'] }} + Deleted: {{ certificate['deleted'] }}

created on {{ certificate['created'].strftime('%Y-%m-%d') }}

- {% if certificate['revoked'] == 0 %} - - - {% endif %}
{% if not loop.last %}
diff --git a/certweb/templates/pubkeys/index.html b/certweb/templates/pubkeys/index.html index ea8c062..5d414bc 100644 --- a/certweb/templates/pubkeys/index.html +++ b/certweb/templates/pubkeys/index.html @@ -17,40 +17,41 @@ {% if g.user %} {% for pubkey in pubkeys %} {% if ( pubkey['deleted'] == 0 and pubkey['user_id'] == g.user['id'] ) or user['admin'] == 1 %} -
+

- - {% if pubkey['revoked'] != 0 %} -
revoked key
- - {% endif %} + + ({{ pubkey['id'] }}): {{ pubkey['key_name'] }}

+ {% if pubkey['revoked'] != 0 %} +
this pubkey was revoked manually
+ {% endif %}
{% if g.user['id'] == pubkey['user_id'] %} - Edit - {% if pubkey['deleted'] == 0 %} - Delete - Delete final - {% endif %} - {% if pubkey['revoked'] == 0 %} - Revoke - {% endif %} + Edit + {% if pubkey['deleted'] == 0 %} + {% endif %} + {% if pubkey['revoked'] == 0 %} +
+ +
+ {% else %} + Delete + {% endif %} {% endif %}
- {% if user['admin'] == 1 %} -
owner: {{ pubkey['username']}}
- {% endif %} -
fingerprint: {{ pubkey['fingerprint'] }}
-
-
{{ request.form['ssh_pubkey'] or pubkey['ssh_pubkey'] }}
+
+ + {% if user['admin'] == 1 %} +
owner: {{ pubkey['username']}}
+ {% endif %} +
fingerprint:
{{ pubkey['fingerprint'] }}
+
pubkey:
{{ request.form['ssh_pubkey'] or pubkey['ssh_pubkey'] }}
+

registered on {{ pubkey['created'].strftime('%Y-%m-%d') }}

- -
diff --git a/certweb/templates/pubkeys/update.html b/certweb/templates/pubkeys/update.html index b88f803..e40f6bf 100644 --- a/certweb/templates/pubkeys/update.html +++ b/certweb/templates/pubkeys/update.html @@ -5,6 +5,9 @@ {% endblock %} {% block content %} +
+ +

-
    -
  • - -
    -
{% endblock %}