From 3f77b0fc8b3f1c00902ad6a12747e8b0a10ac50d Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 29 Jun 2018 13:01:22 +0200 Subject: Move user password form to security settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Settings/Manager.php | 2 +- lib/private/Settings/Personal/Security.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 4ee594c090f..bbc0ac7e4db 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -308,7 +308,7 @@ class Manager implements IManager { } if($section === 'security') { /** @var ISettings $form */ - $form = new Personal\Security(); + $form = new Personal\Security($this->userManager); $forms[$form->getPriority()] = [$form]; } if ($section === 'additional') { diff --git a/lib/private/Settings/Personal/Security.php b/lib/private/Settings/Personal/Security.php index ecbd1199d11..efcfd5589ce 100644 --- a/lib/private/Settings/Personal/Security.php +++ b/lib/private/Settings/Personal/Security.php @@ -25,16 +25,33 @@ namespace OC\Settings\Personal; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IUserManager; use OCP\Settings\ISettings; class Security implements ISettings { + private $userManager; + + public function __construct( + IUserManager $userManager + ) { + $this->userManager = $userManager; + } + /** * @return TemplateResponse returns the instance with all parameters set, ready to be rendered * @since 9.1 */ public function getForm() { - return new TemplateResponse('settings', 'settings/personal/security'); + $user = $this->userManager->get(\OC_User::getUser()); + $passwordChangeSupported = false; + if ($user !== null) { + $passwordChangeSupported = $user->canChangePassword(); + } + + return new TemplateResponse('settings', 'settings/personal/security', [ + 'passwordChangeSupported' => $passwordChangeSupported + ]); } /** -- cgit v1.2.3