Fix setup utility setting correct value to env var API

Fix IF statement for enabling API in nginx.conf
Use safer command for regenerating example API token.
main
Dimitri Huisman 2 years ago
parent 9bd76536a1
commit 0673d32306
No known key found for this signature in database

@ -252,7 +252,7 @@ http {
{% endif %}
{% endif %}
{% if API %}
{% if API == 'true' %}
location ~ {{ WEB_API or '/api' }} {
include /etc/nginx/proxy.conf;
proxy_pass http://$admin;

@ -1,12 +1,7 @@
//API_TOKEN generator
var chars = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var tokenLength = 12;
var token = "";
for (var i = 0; i <= tokenLength; i++) {
var randomNumber = Math.floor(Math.random() * chars.length);
token += chars.substring(randomNumber, randomNumber +1);
}
var random_array = new Uint32Array(2);
crypto.getRandomValues(random_array);
var token = random_array[0].toString() + random_array[1].toString();
$(document).ready(function() {
if ($("#webmail").val() == 'none') {
@ -53,7 +48,7 @@ $(document).ready(function() {
$("#api_token_label").show();
} else {
$("#api_path").hide();
$("#api_path").val("/api")
$("#api_path").val("")
$("#api_token").hide();
$("#api_token").prop('required',false);
$("#api_token").val("");
@ -69,7 +64,7 @@ $(document).ready(function() {
$("#api_token_label").show();
} else {
$("#api_path").hide();
$("#api_path").val("/api")
$("#api_path").val("")
$("#api_token").hide();
$("#api_token").prop('required',false);
$("#api_token").val("");

@ -93,7 +93,7 @@ manage your email domains, users, etc.</p>
It is not possible to use the API without an API token.</p>
<div class="form-group">
<input type="checkbox" name="api_enabled" value="false" id="api" >
<input type="checkbox" name="api_enabled" value="true" id="api" >
<label>Enable the API (and path to the API)</label>
<input class="form-control" type="text" name="api_path" id="api_path" style="display: none">
<label name="api_token_label" id="api_token_label">API token</label>

Loading…
Cancel
Save