Skip to content

Commit 1796b82

Browse files
authored
Merge pull request #49007 from nextcloud/backport/48992/stable28
[stable28] fix: add PasswordConfirmationRequired to saveGlobalCredentials
2 parents c1febd3 + c481f20 commit 1796b82

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

apps/files_external/js/settings.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,30 +1492,37 @@ window.addEventListener('DOMContentLoaded', function() {
14921492
}
14931493
});
14941494

1495-
$('#global_credentials').on('submit', function() {
1496-
var $form = $(this);
1495+
function _submitCredentials(success) {
14971496
var uid = $form.find('[name=uid]').val();
14981497
var user = $form.find('[name=username]').val();
14991498
var password = $form.find('[name=password]').val();
1500-
var $submit = $form.find('[type=submit]');
1501-
$submit.val(t('files_external', 'Saving …'));
15021499
$.ajax({
15031500
type: 'POST',
15041501
contentType: 'application/json',
15051502
data: JSON.stringify({
1506-
uid: uid,
1507-
user: user,
1508-
password: password
1503+
uid,
1504+
user,
1505+
password,
15091506
}),
15101507
url: OC.generateUrl('apps/files_external/globalcredentials'),
15111508
dataType: 'json',
1512-
success: function() {
1509+
success,
1510+
});
1511+
}
1512+
1513+
$('#global_credentials').on('submit', function() {
1514+
var $form = $(this);
1515+
var $submit = $form.find('[type=submit]');
1516+
$submit.val(t('files_external', 'Saving …'));
1517+
1518+
window.OC.PasswordConfirmation
1519+
.requirePasswordConfirmation(() => _submitCredentials(function() {
15131520
$submit.val(t('files_external', 'Saved'));
15141521
setTimeout(function(){
15151522
$submit.val(t('files_external', 'Save'));
15161523
}, 2500);
1517-
}
1518-
});
1524+
}));
1525+
15191526
return false;
15201527
});
15211528

apps/files_external/lib/Controller/AjaxController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
3232
use OCA\Files_External\Lib\Auth\PublicKey\RSA;
3333
use OCP\AppFramework\Controller;
34+
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
35+
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
3436
use OCP\AppFramework\Http\JSONResponse;
3537
use OCP\IGroupManager;
3638
use OCP\IRequest;
@@ -97,13 +99,13 @@ public function getSshKeys($keyLength = 1024) {
9799
}
98100

99101
/**
100-
* @NoAdminRequired
101-
*
102102
* @param string $uid
103103
* @param string $user
104104
* @param string $password
105105
* @return bool
106106
*/
107+
#[NoAdminRequired]
108+
#[PasswordConfirmationRequired]
107109
public function saveGlobalCredentials($uid, $user, $password) {
108110
$currentUser = $this->userSession->getUser();
109111
if ($currentUser === null) {

0 commit comments

Comments
 (0)