Skip to content

Commit de9f5c4

Browse files
authored
Merge pull request #48373 from nextcloud/fix/788/add-password-confirmation-required-to-user-storage-create
fix: add PasswordConfirmationRequired to create user storages endpoint
2 parents d4dffc1 + 1e13776 commit de9f5c4

2 files changed

Lines changed: 25 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
@@ -267,14 +267,25 @@ StorageConfig.prototype = {
267267
* @param {Function} [options.error] error callback
268268
*/
269269
save: function(options) {
270-
var self = this;
271270
var url = OC.generateUrl(this._url);
272271
var method = 'POST';
273272
if (_.isNumber(this.id)) {
274273
method = 'PUT';
275274
url = OC.generateUrl(this._url + '/{id}', {id: this.id});
276275
}
277276

277+
window.OC.PasswordConfirmation.requirePasswordConfirmation(() => this._save(method, url, options), options.error);
278+
},
279+
280+
/**
281+
* Private implementation of the save function (called after potential password confirmation)
282+
* @param {string} method
283+
* @param {string} url
284+
* @param {{success: Function, error: Function}} options
285+
*/
286+
_save: function(method, url, options) {
287+
self = this;
288+
278289
$.ajax({
279290
type: method,
280291
url: url,
@@ -348,6 +359,15 @@ StorageConfig.prototype = {
348359
}
349360
return;
350361
}
362+
363+
window.OC.PasswordConfirmation.requirePasswordConfirmation(() => this._destroy(options), options.error)
364+
},
365+
366+
/**
367+
* Private implementation of the DELETE method called after password confirmation
368+
* @param {{ success: Function, error: Function }} options
369+
*/
370+
_destroy: function(options) {
351371
$.ajax({
352372
type: 'DELETE',
353373
url: OC.generateUrl(this._url + '/{id}', {id: this.id}),

apps/files_external/lib/Controller/UserStoragesController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCA\Files_External\Service\UserStoragesService;
1414
use OCP\AppFramework\Http;
1515
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
16+
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
1617
use OCP\AppFramework\Http\DataResponse;
1718
use OCP\IConfig;
1819
use OCP\IGroupManager;
@@ -99,6 +100,7 @@ public function show($id, $testOnly = true) {
99100
* @return DataResponse
100101
*/
101102
#[NoAdminRequired]
103+
#[PasswordConfirmationRequired]
102104
public function create(
103105
$mountPoint,
104106
$backend,
@@ -154,6 +156,7 @@ public function create(
154156
* @return DataResponse
155157
*/
156158
#[NoAdminRequired]
159+
#[PasswordConfirmationRequired]
157160
public function update(
158161
$id,
159162
$mountPoint,
@@ -205,6 +208,7 @@ public function update(
205208
* {@inheritdoc}
206209
*/
207210
#[NoAdminRequired]
211+
#[PasswordConfirmationRequired]
208212
public function destroy($id) {
209213
return parent::destroy($id);
210214
}

0 commit comments

Comments
 (0)