Skip to content

Commit

Permalink
Merge pull request #48748 from nextcloud/backport/48373/stable30
Browse files Browse the repository at this point in the history
[stable30] fix: add PasswordConfirmationRequired to create user storages endpoint
  • Loading branch information
susnux authored Oct 23, 2024
2 parents 0fef593 + d613e8a commit c3d52f6
Show file tree
Hide file tree
Showing 2 changed files with 25 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 @@ -267,14 +267,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 @@ -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}),
Expand Down
4 changes: 4 additions & 0 deletions apps/files_external/lib/Controller/UserStoragesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,6 +100,7 @@ public function show($id, $testOnly = true) {
* @return DataResponse
*/
#[NoAdminRequired]
#[PasswordConfirmationRequired]
public function create(
$mountPoint,
$backend,
Expand Down Expand Up @@ -154,6 +156,7 @@ public function create(
* @return DataResponse
*/
#[NoAdminRequired]
#[PasswordConfirmationRequired]
public function update(
$id,
$mountPoint,
Expand Down Expand Up @@ -205,6 +208,7 @@ public function update(
* {@inheritdoc}
*/
#[NoAdminRequired]
#[PasswordConfirmationRequired]
public function destroy($id) {
return parent::destroy($id);
}
Expand Down

0 comments on commit c3d52f6

Please sign in to comment.