Fixing API Keys

This commit is contained in:
Silversthorn 2024-07-28 19:27:52 +02:00
parent 56c233bc22
commit facc05800b
2 changed files with 26 additions and 23 deletions

View File

@ -366,6 +366,20 @@ noscript.noscript-warning {
color: var(--purple); color: var(--purple);
} }
/**************************************************************/
/**************************************************************/
/* CSS for API Keys Displays */
/**************************************************************/
.api-key {
white-space: pre-wrap;
color: white;
word-break: break-all;
background: grey;
border-radius: 5px;
}
/**************************************************************/ /**************************************************************/
div.form-group.reset-secret { div.form-group.reset-secret {
background: rgba(243, 21, 6, 0.3); background: rgba(243, 21, 6, 0.3);
@ -380,3 +394,5 @@ div.form-group.reset-secret {
.hidden-input { .hidden-input {
margin-left: -40px; margin-left: -40px;
} }
/**************************************************************/

View File

@ -31,13 +31,11 @@
<div class="card-body pt-0"> <div class="card-body pt-0">
<ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist"> <ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/panel/edit_user?id={{ data['user']['user_id'] }}&subpage=config" <a class="nav-link" href="/panel/edit_user?id={{ data['user']['user_id'] }}&subpage=config" role="tab" aria-selected="false">
role="tab" aria-selected="false">
<i class="fas fa-cogs"></i>{{ translate('apiKeys', 'config', data['lang']) }}</a> <i class="fas fa-cogs"></i>{{ translate('apiKeys', 'config', data['lang']) }}</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" <a class="nav-link active" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" role="tab" aria-selected="true">
role="tab" aria-selected="true">
<i class="fas fa-key"></i>{{ translate('apiKeys', 'apiKeys', data['lang']) }}</a> <i class="fas fa-key"></i>{{ translate('apiKeys', 'apiKeys', data['lang']) }}</a>
</li> </li>
</ul> </ul>
@ -86,13 +84,9 @@
apikey.server_permissions }} apikey.server_permissions }}
{{ translate('apiKeys', 'crafty', data['lang']) }} {{ {{ translate('apiKeys', 'crafty', data['lang']) }} {{
apikey.crafty_permissions }}</td> apikey.crafty_permissions }}</td>
<td><button class="btn btn-danger delete-api-key" <td><button class="btn btn-danger delete-api-key" data-key-id="{{ apikey.token_id }}" data-key-name="{{ apikey.name }}">{{translate('panelConfig',
data-key-id="{{ apikey.token_id }}"
data-key-name="{{ apikey.name }}">{{translate('panelConfig',
'delete', data['lang'])}}</button> 'delete', data['lang'])}}</button>
<button class="btn btn-outline-primary get-a-token" <button class="btn btn-outline-primary get-a-token" data-key-id="{{ apikey.token_id }}" data-key-name="{{ apikey.name }}">{{translate('apiKeys',
data-key-id="{{ apikey.token_id }}"
data-key-name="{{ apikey.name }}">{{translate('apiKeys',
'getToken', data['lang'])}}</button> 'getToken', data['lang'])}}</button>
</td> </td>
</tr> </tr>
@ -118,8 +112,7 @@
<label class="form-label" for="username">{{ translate('apiKeys', 'name', <label class="form-label" for="username">{{ translate('apiKeys', 'name',
data['lang']) }}<small class="text-muted ml-1"> - {{ data['lang']) }}<small class="text-muted ml-1"> - {{
translate('apiKeys', 'nameDesc', data['lang']) }}</small> </label> translate('apiKeys', 'nameDesc', data['lang']) }}</small> </label>
<input type="text" class="form-control" name="name" id="name" <input type="text" class="form-control" name="name" id="name" placeholder="API Key">
placeholder="API Key">
</div> </div>
<table class="table table-hover mb-3"> <table class="table table-hover mb-3">
@ -136,9 +129,7 @@
}}</label> }}</label>
</td> </td>
<td> <td>
<input type="checkbox" class="server_perm" <input type="checkbox" class="server_perm" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" value="1">
id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1">
</td> </td>
</tr> </tr>
{% end %} {% end %}
@ -149,13 +140,9 @@
</td> </td>
<td> <td>
{% if permission in data['user_crafty_permissions'] %} {% if permission in data['user_crafty_permissions'] %}
<input type="checkbox" class="crafty_perm" <input type="checkbox" class="crafty_perm" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" value="1">
id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1">
{% else %} {% else %}
<input type="checkbox" class="crafty_perm" <input type="checkbox" class="crafty_perm" id="permission_{{ permission.name }}" name="permission_{{ permission.name }}" value="1" disabled>
id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1" disabled>
{% end %} {% end %}
</td> </td>
</tr> </tr>
@ -306,7 +293,7 @@
if (responseData.status === "ok") { if (responseData.status === "ok") {
bootbox.alert({ bootbox.alert({
title: `API token for ${keyName}`, title: `API token for ${keyName}`,
message: `Here is an API token for ${keyName}:\n<pre style="white-space: pre-wrap;color:white;word-break:break-all;background: grey;border-radius: 5px;">${responseData.data}</pre>` message: `Here is an API token for ${keyName}:\n<pre class="api-key">${responseData.data}</pre>`
}); });
} else { } else {