diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-19 18:40:47 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-18 12:10:50 +0100 |
commit | 62855c08ffbc7697e43f8aeca42095add8b84986 (patch) | |
tree | 07efb188935bdf52715eab6e893c6d49993dc8aa | |
parent | cc33f8695bdbbb2869608a78f9fb298eddc8929b (diff) | |
download | nextcloud-server-62855c08ffbc7697e43f8aeca42095add8b84986.tar.gz nextcloud-server-62855c08ffbc7697e43f8aeca42095add8b84986.zip |
Require confirmation when changing the email settings
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | settings/Controller/MailSettingsController.php | 6 | ||||
-rw-r--r-- | settings/js/admin.js | 47 |
2 files changed, 43 insertions, 10 deletions
diff --git a/settings/Controller/MailSettingsController.php b/settings/Controller/MailSettingsController.php index 84423aa8e29..108ac3f393a 100644 --- a/settings/Controller/MailSettingsController.php +++ b/settings/Controller/MailSettingsController.php @@ -73,6 +73,9 @@ class MailSettingsController extends Controller { /** * Sets the email settings + * + * @PasswordConfirmationRequired + * * @param string $mail_domain * @param string $mail_from_address * @param string $mail_smtpmode @@ -116,6 +119,9 @@ class MailSettingsController extends Controller { /** * Store the credentials used for SMTP in the config + * + * @PasswordConfirmationRequired + * * @param string $mail_smtpname * @param string $mail_smtppassword * @return array diff --git a/settings/js/admin.js b/settings/js/admin.js index 7c2b507280f..094b12b2bab 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -172,21 +172,48 @@ $(document).ready(function(){ } }); - $('#mail_general_settings_form').change(function(){ + var changeEmailSettings = function() { + if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { + OC.PasswordConfirmation.requirePasswordConfirmation(changeEmailSettings); + return; + } + OC.msg.startSaving('#mail_settings_msg'); - var post = $( "#mail_general_settings_form" ).serialize(); - $.post(OC.generateUrl('/settings/admin/mailsettings'), post, function(data){ - OC.msg.finishedSaving('#mail_settings_msg', data); + $.ajax({ + url: OC.generateUrl('/settings/admin/mailsettings'), + type: 'POST', + data: $('#mail_general_settings_form').serialize(), + success: function(data){ + OC.msg.finishedSaving('#mail_settings_msg', data); + }, + error: function(data){ + OC.msg.finishedError('#mail_settings_msg', data.responseJSON.message); + } }); - }); + }; + + var toggleEmailCredentials = function() { + if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { + OC.PasswordConfirmation.requirePasswordConfirmation(toggleEmailCredentials); + return; + } - $('#mail_credentials_settings_submit').click(function(){ OC.msg.startSaving('#mail_settings_msg'); - var post = $( "#mail_credentials_settings" ).serialize(); - $.post(OC.generateUrl('/settings/admin/mailsettings/credentials'), post, function(data){ - OC.msg.finishedSaving('#mail_settings_msg', data); + $.ajax({ + url: OC.generateUrl('/settings/admin/mailsettings/credentials'), + type: 'POST', + data: $('#mail_credentials_settings').serialize(), + success: function(data){ + OC.msg.finishedSaving('#mail_settings_msg', data); + }, + error: function(data){ + OC.msg.finishedError('#mail_settings_msg', data.responseJSON.message); + } }); - }); + }; + + $('#mail_general_settings_form').change(changeEmailSettings); + $('#mail_credentials_settings_submit').click(toggleEmailCredentials); $('#sendtestemail').click(function(event){ event.preventDefault(); |