Require confirmation when changing the email settings

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2016-09-19 18:40:47 +02:00 committed by Lukas Reschke
parent cc33f8695b
commit 62855c08ff
No known key found for this signature in database
GPG key ID: B9F6980CF6E759B1
2 changed files with 45 additions and 12 deletions

View file

@ -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

View file

@ -172,21 +172,48 @@ $(document).ready(function(){
}
});
$('#mail_general_settings_form').change(function(){
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);
});
});
var changeEmailSettings = function() {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
OC.PasswordConfirmation.requirePasswordConfirmation(changeEmailSettings);
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'),
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;
}
OC.msg.startSaving('#mail_settings_msg');
$.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();