aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryemkareems <yemkareems@gmail.com>2024-10-30 11:29:52 +0530
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-10-30 11:36:39 +0000
commita967355756d350334468ba27ac3a904d84d3682d (patch)
tree37031c2c3bb52f7e858683a1c3e0622b331c4b37
parent45469eef8504d00431a9e1da38cb704d36be10b2 (diff)
downloadnextcloud-server-a967355756d350334468ba27ac3a904d84d3682d.tar.gz
nextcloud-server-a967355756d350334468ba27ac3a904d84d3682d.zip
fix: add PasswordConfirmationRequired to saveGlobalCredentialsbackport/48992/stable30
Co-authored-by: yemkareems <yemkareems@gmail.com> Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--apps/files_external/js/settings.js27
-rw-r--r--apps/files_external/lib/Controller/AjaxController.php2
2 files changed, 19 insertions, 10 deletions
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
index 5cbd011bcc1..61f1696545a 100644
--- a/apps/files_external/js/settings.js
+++ b/apps/files_external/js/settings.js
@@ -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;
});
diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php
index 9faba64416f..12a9a45b906 100644
--- a/apps/files_external/lib/Controller/AjaxController.php
+++ b/apps/files_external/lib/Controller/AjaxController.php
@@ -10,6 +10,7 @@ use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
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;
@@ -82,6 +83,7 @@ class AjaxController extends Controller {
* @return bool
*/
#[NoAdminRequired]
+ #[PasswordConfirmationRequired]
public function saveGlobalCredentials($uid, $user, $password) {
$currentUser = $this->userSession->getUser();
if ($currentUser === null) {