Skip to content

Commit

Permalink
fix: Add frontend code for password confirmation
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>

[skip ci]
  • Loading branch information
susnux authored and backportbot[bot] committed Oct 24, 2024
1 parent ebb2915 commit abd5a85
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion apps/files_external/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,25 @@ 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)) {
method = 'PUT';
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,
Expand Down Expand Up @@ -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}),
Expand Down

0 comments on commit abd5a85

Please sign in to comment.