1414 </ nav >
1515 </ div >
1616
17- < article class ="message is-warning ">
18- < div class ="message-body ">
19- < strong > An API key is like a password and should be treated with the same care.</ strong >
20- </ div >
21- </ article >
22-
23- < div class ="field ">
24- < label class ="label "> API Key</ label >
25- < div class ="control has-icons-left ">
26- < input class ="input " type ="text " value ="{{ request.user.auth_token.key|default:'Not available' }} " readonly >
27- < span class ="icon is-small is-left ">
28- < i class ="fa-solid fa-key "> </ i >
29- </ span >
17+ < div class ="columns ">
18+ < div class ="column is-7 ">
19+ < div class ="content ">
20+ < p >
21+ Your personal API key provides access to the < a href ="{% url 'project-list' %} " target ="_blank "> REST API</ a > .< br >
22+ < strong > Treat it like a password and keep it secure.</ strong >
23+ </ p >
24+ {% if request.user.api_token %}
25+ < div class ="notification is-info is-light mb-4 ">
26+ Your API key < strong > {{ request.user.api_token.prefix }}...</ strong >
27+ was generated on {{ request.user.api_token.created }}< br >
28+ For security reasons, the full key is only shown once at generation time.< br >
29+ If you lose it, you will need to regenerate a new one.
30+ </ div >
31+ {% else %}
32+ < div class ="notification is-warning is-light mb-4 ">
33+ < strong > No API key created.</ strong > < br >
34+ Generate one using the button below to access the REST API.
35+ </ div >
36+ {% endif %}
37+ </ div >
38+ < div class ="buttons ">
39+ < button type ="button " class ="button is-link is-outlined modal-button ">
40+ Generate API key
41+ </ button >
42+ {% if request.user.api_token %}
43+ < button type ="button " class ="button is-danger is-outlined modal-button ">
44+ Revoke API key
45+ </ button >
46+ {% endif %}
47+ </ div >
3048 </ div >
3149 </ div >
3250
51+ < form action ="{% url 'generate_api_key' %} " id ="generate-api-key-form " method ="post "> {% csrf_token %}
52+ < button type ="submit " class ="btn btn-success "> Generate</ button >
53+ </ form >
54+
55+ < form action ="{% url 'revoke_api_key' %} " id ="revoke-api-key-form " method ="post "> {% csrf_token %}
56+ < button type ="submit " class ="btn btn-danger "> Revoke API key</ button >
57+ </ form >
58+
3359 </ section >
3460</ div >
3561{% endblock %}
0 commit comments