vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 161cccca301de4e1a7c10168c66da2b34c80da3d
parent 1f775f441463b8e8ea4b8823a7a8c27d3fe8aeb8
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Thu,  5 Mar 2020 00:05:52 +0100

Merge pull request #892 from BlackDex/smtp-test-button

Relocated SMTP test input+button.
Diffstat:
Msrc/static/templates/admin/page.hbs | 43+++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/static/templates/admin/page.hbs b/src/static/templates/admin/page.hbs @@ -72,16 +72,6 @@ environment. </div> - <div id="smtp-test-form-block" class="align-items-center mb-3 text-white-50 bg-secondary"> - <h6 class="mb-0 text-white">SMTP Test</h6> - <small>Email:</small> - - <form class="form-inline" id="smtp-test-form" onsubmit="smtpTest(); return false;"> - <input type="email" class="form-control w-50 mr-2" id="smtp-test-email" placeholder="Enter email"> - <button type="submit" class="btn btn-primary">Send test email</button> - </form> - </div> - <form class="form accordion" id="config-form" onsubmit="saveConfig(); return false;"> {{#each config}} {{#if groupdoc}} @@ -121,6 +111,17 @@ </div> {{/if}} {{/each}} + {{#case group "smtp"}} + <div class="form-group row pt-3 border-top" title="Send a test email to given email address"> + <label for="smtp-test-email" class="col-sm-3 col-form-label">Test SMTP</label> + <div class="col-sm-8 input-group"> + <input class="form-control" id="smtp-test-email" type="email" placeholder="Enter test email"> + <div class="input-group-append"> + <button type="button" class="btn btn-outline-primary" onclick="smtpTest(); return false;">Send test email</button> + </div> + </div> + </div> + {{/case}} </div> </div> {{/if}} @@ -202,7 +203,10 @@ <script> function reload() { window.location.reload(); } - function msg(text) { text && alert(text); reload(); } + function msg(text, reload_page = true) { + text && alert(text); + reload_page && reload(); + } function identicon(email) { const data = new Identicon(md5(email), { size: 48, format: 'svg' }); return "data:image/svg+xml;base64," + data.toString(); @@ -217,7 +221,7 @@ } return false; } - function _post(url, successMsg, errMsg, body) { + function _post(url, successMsg, errMsg, body, reload_page = true) { fetch(url, { method: 'POST', body: body, @@ -225,7 +229,7 @@ credentials: "same-origin", headers: { "Content-Type": "application/json" } }).then( resp => { - if (resp.ok) { msg(successMsg); return Promise.reject({error: false}); } + if (resp.ok) { msg(successMsg, reload_page); return Promise.reject({error: false}); } respStatus = resp.status; respStatusText = resp.statusText; return resp.text(); @@ -237,10 +241,10 @@ return Promise.reject({body:respStatus + ' - ' + respStatusText, error: true}); } }).then( apiMsg => { - msg(errMsg + "\n" + apiMsg); + msg(errMsg + "\n" + apiMsg, reload_page); }).catch( e => { if (e.error === false) { return true; } - else { msg(errMsg + "\n" + e.body); } + else { msg(errMsg + "\n" + e.body, reload_page); } }); } function deleteUser(id, mail) { @@ -283,12 +287,11 @@ return false; } function smtpTest() { - inv = document.getElementById("smtp-test-email"); - data = JSON.stringify({ "email": inv.value }); - inv.value = ""; + test_email = document.getElementById("smtp-test-email"); + data = JSON.stringify({ "email": test_email.value }); _post("{{urlpath}}/admin/test/smtp/", "SMTP Test email sent correctly", - "Error sending SMTP test email", data); + "Error sending SMTP test email", data, false); return false; } function getFormData() { @@ -329,7 +332,7 @@ function backupDatabase() { _post("{{urlpath}}/admin/config/backup_db", "Backup created successfully", - "Error creating backup"); + "Error creating backup", null, false); return false; } function masterCheck(check_id, inputs_query) {