From 501bea822641018dca5e085f08f1efc3c71a540a Mon Sep 17 00:00:00 2001 From: yemkareems Date: Thu, 26 Sep 2024 15:05:03 +0530 Subject: [PATCH 1/3] fix: add PasswordConfirmationRequired to create user storages endpoint Signed-off-by: yemkareems --- apps/files_external/lib/Controller/UserStoragesController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files_external/lib/Controller/UserStoragesController.php b/apps/files_external/lib/Controller/UserStoragesController.php index a85aa3faa96f3..8efbc741409a9 100644 --- a/apps/files_external/lib/Controller/UserStoragesController.php +++ b/apps/files_external/lib/Controller/UserStoragesController.php @@ -13,6 +13,7 @@ use OCA\Files_External\Service\UserStoragesService; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired; use OCP\AppFramework\Http\DataResponse; use OCP\IConfig; use OCP\IGroupManager; @@ -99,6 +100,7 @@ public function show($id, $testOnly = true) { * @return DataResponse */ #[NoAdminRequired] + #[PasswordConfirmationRequired] public function create( $mountPoint, $backend, From c9075d337927d6c7929fe7249b9f818836cd522d Mon Sep 17 00:00:00 2001 From: yemkareems Date: Mon, 14 Oct 2024 18:29:45 +0530 Subject: [PATCH 2/3] fix: add PasswordConfirmationRequired to update and delete method Signed-off-by: yemkareems --- apps/files_external/lib/Controller/UserStoragesController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files_external/lib/Controller/UserStoragesController.php b/apps/files_external/lib/Controller/UserStoragesController.php index 8efbc741409a9..0ebfd6bcc4e77 100644 --- a/apps/files_external/lib/Controller/UserStoragesController.php +++ b/apps/files_external/lib/Controller/UserStoragesController.php @@ -156,6 +156,7 @@ public function create( * @return DataResponse */ #[NoAdminRequired] + #[PasswordConfirmationRequired] public function update( $id, $mountPoint, @@ -207,6 +208,7 @@ public function update( * {@inheritdoc} */ #[NoAdminRequired] + #[PasswordConfirmationRequired] public function destroy($id) { return parent::destroy($id); } From d613e8a2e34751469c9d74ed0679fbb766e6015d Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 14 Oct 2024 15:12:16 +0200 Subject: [PATCH 3/3] fix: Add frontend code for password confirmation Signed-off-by: Ferdinand Thiessen --- apps/files_external/js/settings.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 582276cad0940..5cbd011bcc1ba 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -267,7 +267,6 @@ StorageConfig.prototype = { * @param {Function} [options.error] error callback */ save: function(options) { - var self = this; var url = OC.generateUrl(this._url); var method = 'POST'; if (_.isNumber(this.id)) { @@ -275,6 +274,18 @@ StorageConfig.prototype = { url = OC.generateUrl(this._url + '/{id}', {id: this.id}); } + window.OC.PasswordConfirmation.requirePasswordConfirmation(() => this._save(method, url, options), options.error); + }, + + /** + * Private implementation of the save function (called after potential password confirmation) + * @param {string} method + * @param {string} url + * @param {{success: Function, error: Function}} options + */ + _save: function(method, url, options) { + self = this; + $.ajax({ type: method, url: url, @@ -348,6 +359,15 @@ StorageConfig.prototype = { } return; } + + window.OC.PasswordConfirmation.requirePasswordConfirmation(() => this._destroy(options), options.error) + }, + + /** + * Private implementation of the DELETE method called after password confirmation + * @param {{ success: Function, error: Function }} options + */ + _destroy: function(options) { $.ajax({ type: 'DELETE', url: OC.generateUrl(this._url + '/{id}', {id: this.id}),