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);
}
/**************************************************************/
/**************************************************************/
/* 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 {
background: rgba(243, 21, 6, 0.3);
@ -380,3 +394,5 @@ div.form-group.reset-secret {
.hidden-input {
margin-left: -40px;
}
/**************************************************************/

View File

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