summaryrefslogtreecommitdiffstats
path: root/settings/Controller
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-04-18 16:13:31 -0500
committerGitHub <noreply@github.com>2017-04-18 16:13:31 -0500
commitd379ac7545d5b4d69c5419501a5084073378bc57 (patch)
treef7aaba02fa10dc3c7f457f66797d905cc818d715 /settings/Controller
parentc40b7acb09f99d0fa5e179345de141409356a55d (diff)
parentd2c4440ed69548db89c88f7003396f607947446f (diff)
downloadnextcloud-server-d379ac7545d5b4d69c5419501a5084073378bc57.tar.gz
nextcloud-server-d379ac7545d5b4d69c5419501a5084073378bc57.zip
Merge pull request #4372 from nextcloud/smtp-password
Don't put the SMTP password into the HTML code
Diffstat (limited to 'settings/Controller')
-rw-r--r--settings/Controller/MailSettingsController.php49
1 files changed, 15 insertions, 34 deletions
diff --git a/settings/Controller/MailSettingsController.php b/settings/Controller/MailSettingsController.php
index 8137b4da53c..f0fd7a52f0b 100644
--- a/settings/Controller/MailSettingsController.php
+++ b/settings/Controller/MailSettingsController.php
@@ -1,5 +1,6 @@
<?php
/**
+ * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
@@ -25,6 +26,8 @@
namespace OC\Settings\Controller;
use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use OCP\IL10N;
use OCP\IConfig;
@@ -84,7 +87,7 @@ class MailSettingsController extends Controller {
* @param string $mail_smtpauthtype
* @param int $mail_smtpauth
* @param string $mail_smtpport
- * @return array
+ * @return DataResponse
*/
public function setMailSettings($mail_domain,
$mail_from_address,
@@ -109,12 +112,7 @@ class MailSettingsController extends Controller {
$this->config->setSystemValues($configs);
- return array('data' =>
- array('message' =>
- (string) $this->l10n->t('Saved')
- ),
- 'status' => 'success'
- );
+ return new DataResponse();
}
/**
@@ -124,25 +122,24 @@ class MailSettingsController extends Controller {
*
* @param string $mail_smtpname
* @param string $mail_smtppassword
- * @return array
+ * @return DataResponse
*/
public function storeCredentials($mail_smtpname, $mail_smtppassword) {
+ if ($mail_smtppassword === '********') {
+ return new DataResponse($this->l10n->t('Invalid SMTP password.'), Http::STATUS_BAD_REQUEST);
+ }
+
$this->config->setSystemValues([
'mail_smtpname' => $mail_smtpname,
'mail_smtppassword' => $mail_smtppassword,
]);
- return array('data' =>
- array('message' =>
- (string) $this->l10n->t('Saved')
- ),
- 'status' => 'success'
- );
+ return new DataResponse();
}
/**
* Send a mail to test the settings
- * @return array
+ * @return DataResponse
*/
public function sendTestMail() {
$email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', '');
@@ -157,29 +154,13 @@ class MailSettingsController extends Controller {
if (!empty($errors)) {
throw new \RuntimeException($this->l10n->t('Mail could not be sent. Check your mail server log'));
}
+ return new DataResponse();
} catch (\Exception $e) {
- return [
- 'data' => [
- 'message' => (string) $this->l10n->t('A problem occurred while sending the email. Please revise your settings. (Error: %s)', [$e->getMessage()]),
- ],
- 'status' => 'error',
- ];
+ return new DataResponse($this->l10n->t('A problem occurred while sending the email. Please revise your settings. (Error: %s)', [$e->getMessage()]), Http::STATUS_BAD_REQUEST);
}
-
- return array('data' =>
- array('message' =>
- (string) $this->l10n->t('Email sent')
- ),
- 'status' => 'success'
- );
}
- return array('data' =>
- array('message' =>
- (string) $this->l10n->t('You need to set your user email before being able to send test emails.'),
- ),
- 'status' => 'error'
- );
+ return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST);
}
}