Skip to content

Commit

Permalink
fix: add PasswordConfirmationRequired to saveGlobalCredentials
Browse files Browse the repository at this point in the history
Co-authored-by: yemkareems <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
yemkareems authored and susnux committed Oct 30, 2024
1 parent dac15d1 commit 3b6a36f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 17 additions & 10 deletions apps/files_external/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1488,30 +1488,37 @@ window.addEventListener('DOMContentLoaded', function() {
}
});

$('#global_credentials').on('submit', function() {
var $form = $(this);
function _submitCredentials(success) {
var uid = $form.find('[name=uid]').val();
var user = $form.find('[name=username]').val();
var password = $form.find('[name=password]').val();
var $submit = $form.find('[type=submit]');
$submit.val(t('files_external', 'Saving …'));
$.ajax({
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
uid: uid,
user: user,
password: password
uid,
user,
password,
}),
url: OC.generateUrl('apps/files_external/globalcredentials'),
dataType: 'json',
success: function() {
success,
});
}

$('#global_credentials').on('submit', function() {
var $form = $(this);
var $submit = $form.find('[type=submit]');
$submit.val(t('files_external', 'Saving …'));

window.OC.PasswordConfirmation
.requirePasswordConfirmation(() => _submitCredentials(function() {
$submit.val(t('files_external', 'Saved'));
setTimeout(function(){
$submit.val(t('files_external', 'Save'));
}, 2500);
}
});
}));

return false;
});

Expand Down
2 changes: 2 additions & 0 deletions apps/files_external/lib/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OCA\Files_External\Lib\Auth\PublicKey\RSA;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IGroupManager;
use OCP\IRequest;
Expand Down Expand Up @@ -71,6 +72,7 @@ public function getSshKeys($keyLength = 1024) {
* @return bool
*/
#[NoAdminRequired]
#[PasswordConfirmationRequired]
public function saveGlobalCredentials($uid, $user, $password) {
$currentUser = $this->userSession->getUser();
if ($currentUser === null) {
Expand Down

0 comments on commit 3b6a36f

Please sign in to comment.