From 8434dbf58df64df825bdc551a43887175bde0c7c Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 14 Oct 2024 15:12:16 +0200 Subject: [PATCH] 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 f94d443419ec2..74dfb9300a047 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -271,7 +271,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)) { @@ -279,6 +278,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, @@ -352,6 +363,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}),