diff --git a/setup/static/render.js b/setup/static/render.js index 2d847a2d..b2cdc7c8 100644 --- a/setup/static/render.js +++ b/setup/static/render.js @@ -1,3 +1,13 @@ +//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); + } + $(document).ready(function() { if ($("#webmail").val() == 'none') { $("#webmail_path").hide(); @@ -39,8 +49,15 @@ $(document).ready(function() { $("#api_path").val("/api") $("#api_token").show(); $("#api_token").prop('required',true); - $("#api_token").val(""); + $("#api_token").val(token); $("#api_token_label").show(); + } else { + $("#api_path").hide(); + $("#api_path").val("/api") + $("#api_token").hide(); + $("#api_token").prop('required',false); + $("#api_token").val(""); + $("#api_token_label").hide(); } $("#api").change(function() { if ($(this).is(":checked")) { @@ -48,7 +65,7 @@ $(document).ready(function() { $("#api_path").val("/api"); $("#api_token").show(); $("#api_token").prop('required',true); - $("#api_token").val("") + $("#api_token").val(token) $("#api_token_label").show(); } else { $("#api_path").hide(); diff --git a/setup/templates/steps/config.html b/setup/templates/steps/config.html index 83a3a813..19736448 100644 --- a/setup/templates/steps/config.html +++ b/setup/templates/steps/config.html @@ -93,7 +93,7 @@ manage your email domains, users, etc.
It is not possible to use the API without an API token.