Skip to content

Commit 8434dbf

Browse files
committed
fix: Add frontend code for password confirmation
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 0de59aa commit 8434dbf

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

apps/files_external/js/settings.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,25 @@ StorageConfig.prototype = {
271271
* @param {Function} [options.error] error callback
272272
*/
273273
save: function(options) {
274-
var self = this;
275274
var url = OC.generateUrl(this._url);
276275
var method = 'POST';
277276
if (_.isNumber(this.id)) {
278277
method = 'PUT';
279278
url = OC.generateUrl(this._url + '/{id}', {id: this.id});
280279
}
281280

281+
window.OC.PasswordConfirmation.requirePasswordConfirmation(() => this._save(method, url, options), options.error);
282+
},
283+
284+
/**
285+
* Private implementation of the save function (called after potential password confirmation)
286+
* @param {string} method
287+
* @param {string} url
288+
* @param {{success: Function, error: Function}} options
289+
*/
290+
_save: function(method, url, options) {
291+
self = this;
292+
282293
$.ajax({
283294
type: method,
284295
url: url,
@@ -352,6 +363,15 @@ StorageConfig.prototype = {
352363
}
353364
return;
354365
}
366+
367+
window.OC.PasswordConfirmation.requirePasswordConfirmation(() => this._destroy(options), options.error)
368+
},
369+
370+
/**
371+
* Private implementation of the DELETE method called after password confirmation
372+
* @param {{ success: Function, error: Function }} options
373+
*/
374+
_destroy: function(options) {
355375
$.ajax({
356376
type: 'DELETE',
357377
url: OC.generateUrl(this._url + '/{id}', {id: this.id}),

0 commit comments

Comments
 (0)