diff options
-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(); |