SecuritySettingsController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\Settings\Controller;
  24. use \OCP\AppFramework\Controller;
  25. use OCP\IRequest;
  26. use OCP\IConfig;
  27. /**
  28. * @package OC\Settings\Controller
  29. */
  30. class SecuritySettingsController extends Controller {
  31. /** @var \OCP\IConfig */
  32. private $config;
  33. /**
  34. * @param string $appName
  35. * @param IRequest $request
  36. * @param IConfig $config
  37. */
  38. public function __construct($appName,
  39. IRequest $request,
  40. IConfig $config) {
  41. parent::__construct($appName, $request);
  42. $this->config = $config;
  43. }
  44. /**
  45. * @return array
  46. */
  47. protected function returnSuccess() {
  48. return array(
  49. 'status' => 'success'
  50. );
  51. }
  52. /**
  53. * Add a new trusted domain
  54. * @param string $newTrustedDomain The newly to add trusted domain
  55. * @return array
  56. */
  57. public function trustedDomains($newTrustedDomain) {
  58. $trustedDomains = $this->config->getSystemValue('trusted_domains', []);
  59. $trustedDomains[] = $newTrustedDomain;
  60. $this->config->setSystemValue('trusted_domains', $trustedDomains);
  61. return $this->returnSuccess();
  62. }
  63. }