File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -1492,30 +1492,37 @@ window.addEventListener('DOMContentLoaded', function() {
1492
1492
}
1493
1493
} ) ;
1494
1494
1495
- $ ( '#global_credentials' ) . on ( 'submit' , function ( ) {
1496
- var $form = $ ( this ) ;
1495
+ function _submitCredentials ( success ) {
1497
1496
var uid = $form . find ( '[name=uid]' ) . val ( ) ;
1498
1497
var user = $form . find ( '[name=username]' ) . val ( ) ;
1499
1498
var password = $form . find ( '[name=password]' ) . val ( ) ;
1500
- var $submit = $form . find ( '[type=submit]' ) ;
1501
- $submit . val ( t ( 'files_external' , 'Saving …' ) ) ;
1502
1499
$ . ajax ( {
1503
1500
type : 'POST' ,
1504
1501
contentType : 'application/json' ,
1505
1502
data : JSON . stringify ( {
1506
- uid : uid ,
1507
- user : user ,
1508
- password : password
1503
+ uid,
1504
+ user,
1505
+ password,
1509
1506
} ) ,
1510
1507
url : OC . generateUrl ( 'apps/files_external/globalcredentials' ) ,
1511
1508
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 ( ) {
1513
1520
$submit . val ( t ( 'files_external' , 'Saved' ) ) ;
1514
1521
setTimeout ( function ( ) {
1515
1522
$submit . val ( t ( 'files_external' , 'Save' ) ) ;
1516
1523
} , 2500 ) ;
1517
- }
1518
- } ) ;
1524
+ } ) ) ;
1525
+
1519
1526
return false ;
1520
1527
} ) ;
1521
1528
Original file line number Diff line number Diff line change 31
31
use OCA \Files_External \Lib \Auth \Password \GlobalAuth ;
32
32
use OCA \Files_External \Lib \Auth \PublicKey \RSA ;
33
33
use OCP \AppFramework \Controller ;
34
+ use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
35
+ use OCP \AppFramework \Http \Attribute \PasswordConfirmationRequired ;
34
36
use OCP \AppFramework \Http \JSONResponse ;
35
37
use OCP \IGroupManager ;
36
38
use OCP \IRequest ;
@@ -97,13 +99,13 @@ public function getSshKeys($keyLength = 1024) {
97
99
}
98
100
99
101
/**
100
- * @NoAdminRequired
101
- *
102
102
* @param string $uid
103
103
* @param string $user
104
104
* @param string $password
105
105
* @return bool
106
106
*/
107
+ #[NoAdminRequired]
108
+ #[PasswordConfirmationRequired]
107
109
public function saveGlobalCredentials ($ uid , $ user , $ password ) {
108
110
$ currentUser = $ this ->userSession ->getUser ();
109
111
if ($ currentUser === null ) {
You can’t perform that action at this time.
0 commit comments