From a8859a1c7ab1cae5426a240876cfb04219693a05 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 12 Sep 2024 13:30:47 +0200 Subject: [PATCH] add password confirmation in admin settings Signed-off-by: Julien Veyssier --- lib/Controller/ConfigController.php | 2 ++ package-lock.json | 20 ++++++++++++++++++++ package.json | 1 + src/components/AdminSettings.vue | 4 +++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/Controller/ConfigController.php b/lib/Controller/ConfigController.php index 76e5dbe..9a96904 100644 --- a/lib/Controller/ConfigController.php +++ b/lib/Controller/ConfigController.php @@ -17,6 +17,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired; use OCP\AppFramework\Http\DataResponse; use OCP\IConfig; @@ -76,6 +77,7 @@ public function setConfig(array $values): DataResponse { * @param array $values * @return DataResponse */ + #[PasswordConfirmationRequired] public function setAdminConfig(array $values): DataResponse { foreach ($values as $key => $value) { $this->config->setAppValue(Application::APP_ID, $key, $value); diff --git a/package-lock.json b/package-lock.json index d1e6f05..cb28c93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@nextcloud/initial-state": "^2.2.0", "@nextcloud/l10n": "^3.1.0", "@nextcloud/moment": "^1.3.1", + "@nextcloud/password-confirmation": "^5.1.1", "@nextcloud/router": "^3.0.1", "@nextcloud/vue": "^8.18.0", "vue": "^2.6.11", @@ -2849,6 +2850,25 @@ "npm": "^10.0.0" } }, + "node_modules/@nextcloud/password-confirmation": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@nextcloud/password-confirmation/-/password-confirmation-5.1.1.tgz", + "integrity": "sha512-UlQcjVe/fr/JaJ6TWaRM+yBLIEZRU6RWMy0JoExcA6UVJs2HJrRIyVMuiCLuIYlH23ReJH+z7zFI3+V7vdeJ1Q==", + "license": "MIT", + "dependencies": { + "@nextcloud/axios": "^2.5.0", + "@nextcloud/l10n": "^3.1.0", + "@nextcloud/router": "^3.0.1" + }, + "engines": { + "node": "^20.0.0", + "npm": "^10.0.0" + }, + "peerDependencies": { + "@nextcloud/vue": "^8.0.0", + "vue": "^2.7.16" + } + }, "node_modules/@nextcloud/paths": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@nextcloud/paths/-/paths-2.2.1.tgz", diff --git a/package.json b/package.json index 14be59e..c5fba06 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@nextcloud/initial-state": "^2.2.0", "@nextcloud/l10n": "^3.1.0", "@nextcloud/moment": "^1.3.1", + "@nextcloud/password-confirmation": "^5.1.1", "@nextcloud/router": "^3.0.1", "@nextcloud/vue": "^8.18.0", "vue": "^2.6.11", diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 6d71660..4e64cbf 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -65,6 +65,7 @@ import { generateUrl } from '@nextcloud/router' import axios from '@nextcloud/axios' import { delay } from '../utils.js' import { showSuccess, showError } from '@nextcloud/dialogs' +import { confirmPassword } from '@nextcloud/password-confirmation' export default { name: 'AdminSettings', @@ -97,7 +98,8 @@ export default { this.saveOptions() }, 2000)() }, - saveOptions() { + async saveOptions() { + await confirmPassword() const req = { values: { client_id: this.state.client_id,