diff options
author | Joas Schilling <coding@schilljs.com> | 2017-04-18 15:44:20 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-18 15:44:20 +0200 |
commit | a5b4308a517a66b320ba69be8604144ce74f417e (patch) | |
tree | ef952ee37dd149322cbacea72ce1e099c32bcc2f /settings/Controller/MailSettingsController.php | |
parent | b072d2c49d6f61c2b55abf12e04bdf2166dbd4f4 (diff) | |
download | nextcloud-server-a5b4308a517a66b320ba69be8604144ce74f417e.tar.gz nextcloud-server-a5b4308a517a66b320ba69be8604144ce74f417e.zip |
Don't put the SMTP password into the HTML code
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'settings/Controller/MailSettingsController.php')
-rw-r--r-- | settings/Controller/MailSettingsController.php | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/settings/Controller/MailSettingsController.php b/settings/Controller/MailSettingsController.php index 8137b4da53c..b66c63cfcb6 100644 --- a/settings/Controller/MailSettingsController.php +++ b/settings/Controller/MailSettingsController.php @@ -25,6 +25,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 +86,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 +111,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 +121,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 array|DataResponse */ public function sendTestMail() { $email = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'email', ''); @@ -158,28 +154,13 @@ class MailSettingsController extends Controller { throw new \RuntimeException($this->l10n->t('Mail could not be sent. Check your mail server log')); } } 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()])); } - return array('data' => - array('message' => - (string) $this->l10n->t('Email sent') - ), - 'status' => 'success' - ); + return new DataResponse(); } - 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.')); } } |