]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move password settings
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 30 Jan 2020 12:24:10 +0000 (13:24 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 30 Jan 2020 13:03:28 +0000 (14:03 +0100)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/settings/composer/composer/autoload_classmap.php
apps/settings/composer/composer/autoload_static.php
apps/settings/lib/Settings/Personal/Security.php [deleted file]
apps/settings/lib/Settings/Personal/Security/Password.php [new file with mode: 0644]
apps/settings/templates/settings/personal/security.php [deleted file]
apps/settings/templates/settings/personal/security/password.php [new file with mode: 0644]
apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
apps/settings/tests/Settings/Personal/Security/PasswordTest.php [new file with mode: 0644]
apps/settings/tests/Settings/Personal/SecurityTest.php [deleted file]
lib/private/Settings/Manager.php
tests/lib/Settings/ManagerTest.php

index cf7963ef9014d22d451a942961e176965b345c5a..3e83c20bd388e6c2af3edd6c585dbad0f98a5a12 100644 (file)
@@ -38,8 +38,8 @@ return array(
     'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php',
     'OCA\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
     'OCA\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
-    'OCA\\Settings\\Personal\\Security' => $baseDir . '/../lib/Settings/Personal/Security.php',
     'OCA\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',
+    'OCA\\Settings\\Personal\\Security\\Password' => $baseDir . '/../lib/Settings/Personal/Security/Password.php',
     'OCA\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
     'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php',
     'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir . '/../lib/Sections/Admin/Groupware.php',
index f9805dcff118175f29df455bc22ebd6a77e31161..a76fe97eec9097a6682bf9c6b526dda8c75b8896 100644 (file)
@@ -53,8 +53,8 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
         'OCA\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
         'OCA\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
-        'OCA\\Settings\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security.php',
         'OCA\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
+        'OCA\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
         'OCA\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
         'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php',
         'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php',
diff --git a/apps/settings/lib/Settings/Personal/Security.php b/apps/settings/lib/Settings/Personal/Security.php
deleted file mode 100644 (file)
index f571be0..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Greta Doci <gretadoci@gmail.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Settings\Personal;
-
-use OCP\AppFramework\Http\TemplateResponse;
-use OCP\IUserManager;
-use OCP\Settings\ISettings;
-
-class Security implements ISettings {
-
-       /** @var IUserManager */
-       private $userManager;
-
-       /** @var string|null */
-       private $uid;
-
-       public function __construct(IUserManager $userManager,
-                                                               ?string $UserId) {
-               $this->userManager = $userManager;
-               $this->uid = $UserId;
-       }
-
-       public function getForm(): TemplateResponse {
-               $user = $this->userManager->get($this->uid);
-               $passwordChangeSupported = false;
-               if ($user !== null) {
-                       $passwordChangeSupported = $user->canChangePassword();
-               }
-
-               return new TemplateResponse('settings', 'settings/personal/security', [
-                       'passwordChangeSupported' => $passwordChangeSupported,
-               ]);
-       }
-
-       public function getSection(): string {
-               return 'security';
-       }
-
-       public function getPriority(): int {
-               return 10;
-       }
-}
diff --git a/apps/settings/lib/Settings/Personal/Security/Password.php b/apps/settings/lib/Settings/Personal/Security/Password.php
new file mode 100644 (file)
index 0000000..91d8b92
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Greta Doci <gretadoci@gmail.com>
+ * @author Julius Härtl <jus@bitgrid.net>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Settings\Personal\Security;
+
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IUserManager;
+use OCP\Settings\ISettings;
+
+class Password implements ISettings {
+
+       /** @var IUserManager */
+       private $userManager;
+
+       /** @var string|null */
+       private $uid;
+
+       public function __construct(IUserManager $userManager,
+                                                               ?string $UserId) {
+               $this->userManager = $userManager;
+               $this->uid = $UserId;
+       }
+
+       public function getForm(): TemplateResponse {
+               $user = $this->userManager->get($this->uid);
+               $passwordChangeSupported = false;
+               if ($user !== null) {
+                       $passwordChangeSupported = $user->canChangePassword();
+               }
+
+               return new TemplateResponse('settings', 'settings/personal/security/password', [
+                       'passwordChangeSupported' => $passwordChangeSupported,
+               ]);
+       }
+
+       public function getSection(): string {
+               return 'security';
+       }
+
+       public function getPriority(): int {
+               return 10;
+       }
+}
diff --git a/apps/settings/templates/settings/personal/security.php b/apps/settings/templates/settings/personal/security.php
deleted file mode 100644 (file)
index 23959f7..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-script('settings', [
-       'settings',
-       'templates',
-       'vue-settings-personal-security',
-]);
-
-if($_['passwordChangeSupported']) {
-       script('settings', 'security_password');
-}
-
-?>
-<?php if($_['passwordChangeSupported']) { ?>
-<div id="security-password" class="section">
-       <h2 class="inlineblock"><?php p($l->t('Password'));?></h2>
-       <span id="password-error-msg" class="msg success hidden">Saved</span>
-       <div class="personal-settings-setting-box personal-settings-password-box">
-                       <form id="passwordform">
-                               <label for="pass1" class="hidden-visually"><?php p($l->t('Current password')); ?>: </label>
-                               <input type="password" id="pass1" name="oldpassword"
-                                          placeholder="<?php p($l->t('Current password'));?>"
-                                          autocomplete="off" autocapitalize="none" autocorrect="off" />
-
-                               <div class="personal-show-container">
-                                       <label for="pass2" class="hidden-visually"><?php p($l->t('New password'));?>: </label>
-                                       <input type="password" id="pass2" name="newpassword"
-                                                  placeholder="<?php p($l->t('New password')); ?>"
-                                                  data-typetoggle="#personal-show"
-                                                  autocomplete="off" autocapitalize="none" autocorrect="off" />
-                                       <input type="checkbox" id="personal-show" class="hidden-visually" name="show" /><label for="personal-show" class="personal-show-label"></label>
-                               </div>
-
-                               <input id="passwordbutton" type="submit" value="<?php p($l->t('Change password')); ?>" />
-
-                       </form>
-       </div>
-       <span class="msg"></span>
-</div>
-<?php } ?>
diff --git a/apps/settings/templates/settings/personal/security/password.php b/apps/settings/templates/settings/personal/security/password.php
new file mode 100644 (file)
index 0000000..23959f7
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+script('settings', [
+       'settings',
+       'templates',
+       'vue-settings-personal-security',
+]);
+
+if($_['passwordChangeSupported']) {
+       script('settings', 'security_password');
+}
+
+?>
+<?php if($_['passwordChangeSupported']) { ?>
+<div id="security-password" class="section">
+       <h2 class="inlineblock"><?php p($l->t('Password'));?></h2>
+       <span id="password-error-msg" class="msg success hidden">Saved</span>
+       <div class="personal-settings-setting-box personal-settings-password-box">
+                       <form id="passwordform">
+                               <label for="pass1" class="hidden-visually"><?php p($l->t('Current password')); ?>: </label>
+                               <input type="password" id="pass1" name="oldpassword"
+                                          placeholder="<?php p($l->t('Current password'));?>"
+                                          autocomplete="off" autocapitalize="none" autocorrect="off" />
+
+                               <div class="personal-show-container">
+                                       <label for="pass2" class="hidden-visually"><?php p($l->t('New password'));?>: </label>
+                                       <input type="password" id="pass2" name="newpassword"
+                                                  placeholder="<?php p($l->t('New password')); ?>"
+                                                  data-typetoggle="#personal-show"
+                                                  autocomplete="off" autocapitalize="none" autocorrect="off" />
+                                       <input type="checkbox" id="personal-show" class="hidden-visually" name="show" /><label for="personal-show" class="personal-show-label"></label>
+                               </div>
+
+                               <input id="passwordbutton" type="submit" value="<?php p($l->t('Change password')); ?>" />
+
+                       </form>
+       </div>
+       <span class="msg"></span>
+</div>
+<?php } ?>
index 6837fc101c45e5f7075293e6164e0cf3002393b8..6fd7cf22efee1ad898387ee5aec9169a58bdd79a 100644 (file)
@@ -29,7 +29,7 @@ namespace OCA\Settings\Tests\Settings\Personal\Security;
 
 use OC\Authentication\Token\DefaultToken;
 use OC\Authentication\Token\IProvider as IAuthTokenProvider;
-use OCA\Settings\Personal\Security;
+use OCA\Settings\Personal\Password;
 use OCA\Settings\Personal\Security\Authtokens;
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IInitialStateService;
diff --git a/apps/settings/tests/Settings/Personal/Security/PasswordTest.php b/apps/settings/tests/Settings/Personal/Security/PasswordTest.php
new file mode 100644 (file)
index 0000000..160e4eb
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+declare(strict_types=1);
+
+/**
+ * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Greta Doci <gretadoci@gmail.com>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Settings\Tests\Settings\Personal;
+
+use OCA\Settings\Personal\Security\Password;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IUser;
+use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class PasswordTest extends TestCase {
+
+       /** @var IUserManager|MockObject */
+       private $userManager;
+
+       /** @var string */
+       private $uid;
+
+       /** @var Password */
+       private $section;
+
+       protected function setUp(): void {
+               parent::setUp();
+
+               $this->userManager = $this->createMock(IUserManager::class);
+               $this->uid = 'test123';
+
+               $this->section = new Password(
+                       $this->userManager,
+                       $this->uid
+               );
+       }
+
+       public function testGetForm() {
+               $user = $this->createMock(IUser::class);
+               $this->userManager->expects($this->once())
+                       ->method('get')
+                       ->with($this->uid)
+                       ->willReturn($user);
+               $user->expects($this->once())
+                       ->method('canChangePassword')
+                       ->willReturn(true);
+
+               $form = $this->section->getForm();
+
+               $expected = new TemplateResponse('settings', 'settings/personal/security', [
+                       'passwordChangeSupported' => true,
+               ]);
+               $this->assertEquals($expected, $form);
+       }
+
+}
diff --git a/apps/settings/tests/Settings/Personal/SecurityTest.php b/apps/settings/tests/Settings/Personal/SecurityTest.php
deleted file mode 100644 (file)
index 103bd9d..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Greta Doci <gretadoci@gmail.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Settings\Tests\Settings\Personal;
-
-use OC\Authentication\TwoFactorAuth\ProviderLoader;
-use OCA\Settings\Personal\Security;
-use OCP\AppFramework\Http\TemplateResponse;
-use OCP\IConfig;
-use OCP\IUser;
-use OCP\IUserManager;
-use OCP\IUserSession;
-use PHPUnit\Framework\MockObject\MockObject;
-use Test\TestCase;
-
-class SecurityTest extends TestCase {
-
-       /** @var IUserManager|MockObject */
-       private $userManager;
-
-       /** @var string */
-       private $uid;
-
-       /** @var Security */
-       private $section;
-
-       protected function setUp(): void {
-               parent::setUp();
-
-               $this->userManager = $this->createMock(IUserManager::class);
-               $this->uid = 'test123';
-
-               $this->section = new Security(
-                       $this->userManager,
-                       $this->uid
-               );
-       }
-
-       public function testGetForm() {
-               $user = $this->createMock(IUser::class);
-               $this->userManager->expects($this->once())
-                       ->method('get')
-                       ->with($this->uid)
-                       ->willReturn($user);
-               $user->expects($this->once())
-                       ->method('canChangePassword')
-                       ->willReturn(true);
-
-               $form = $this->section->getForm();
-
-               $expected = new TemplateResponse('settings', 'settings/personal/security', [
-                       'passwordChangeSupported' => true,
-               ]);
-               $this->assertEquals($expected, $form);
-       }
-
-}
index 87ef74aabaad09ce679711d3123e256c00f7083f..157ab9db1d3e269e53df2702d091f3b459e20e3a 100644 (file)
@@ -289,7 +289,7 @@ class Manager implements IManager {
                }
                if ($section === 'security') {
                        /** @var ISettings $form */
-                       $form = $this->container->query(\OCA\Settings\Personal\Security::class);
+                       $form = $this->container->query(\OCA\Settings\Personal\Security\Password::class);
                        $forms[$form->getPriority()] = [$form];
 
                        /** @var ISettings $form */
index 3980990c7b1370010112c805a17d3ecfa113ad8d..7972a4bdbba93488ecd4c59c2317dbbc8e7618ae 100644 (file)
@@ -26,7 +26,7 @@ namespace OCA\Settings\Tests\AppInfo;
 use OC\Settings\Manager;
 use OC\Settings\Section;
 use OCA\Settings\Admin\Sharing;
-use OCA\Settings\Personal\Security;
+use OCA\Settings\Personal\Password;
 use OCP\IDBConnection;
 use OCP\IL10N;
 use OCP\ILogger;
@@ -149,7 +149,7 @@ class ManagerTest extends TestCase {
        }
 
        public function testGetPersonalSettings() {
-               $section = $this->createMock(Security::class);
+               $section = $this->createMock(Password::class);
                $section->expects($this->once())
                        ->method('getPriority')
                        ->willReturn(16);
@@ -159,7 +159,7 @@ class ManagerTest extends TestCase {
                        ->willReturn(100);
                $this->container->expects($this->at(0))
                        ->method('query')
-                       ->with(Security::class)
+                       ->with(Password::class)
                        ->willReturn($section);
                $this->container->expects($this->at(1))
                        ->method('query')