Skip to content

Commit

Permalink
fix: Don't offer already-disabled API keys for disablement (#5262)
Browse files Browse the repository at this point in the history
* fix: Don't offer already-disabled API keys for disablement

Fixes #3441

* Remove test class
  • Loading branch information
larseggert authored Mar 2, 2023
1 parent 5fc93bb commit 276dd08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ietf/ietfauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ class Meta:
@person_required
def apikey_disable(request):
person = request.user.person
choices = [ (k.hash(), str(k)) for k in person.apikeys.all() ]
choices = [ (k.hash(), str(k)) for k in person.apikeys.exclude(valid=False) ]
#
class KeyDeleteForm(forms.Form):
hash = forms.ChoiceField(label='Key', choices=choices)
Expand Down
6 changes: 3 additions & 3 deletions ietf/templates/ietfauth/apikeys.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ <h1>
<td>{{ key.created }}</td>
<td>{{ key.latest }}</td>
<td>{{ key.count }}</td>
<td>{{ key.valid }}</td>
<td class="{{ key.valid|yesno:'text-success,text-danger'}}">{{ key.valid }}</td>
<td>
<code>{{ key.hash }}</code>
<code {% if not key.valid %}class="text-decoration-line-through"{% endif %}>{{ key.hash }}</code>
</td>
<td >
{% if key.valid %}
Expand All @@ -63,4 +63,4 @@ <h1>
{% endblock %}
{% block js %}
<script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}
{% endblock %}

0 comments on commit 276dd08

Please sign in to comment.