mirror of
https://github.com/nextcloud/server.git
synced 2026-07-16 05:13:10 -04:00
Merge pull request #12409 from nextcloud/admin-vue-approval-fix
Use nextcloud-password-confirmation
This commit is contained in:
commit
237c70d3cd
14 changed files with 40 additions and 73 deletions
|
|
@ -1751,7 +1751,7 @@ OC.PasswordConfirmation = {
|
|||
/**
|
||||
* @param {function} callback
|
||||
*/
|
||||
requirePasswordConfirmation: function(callback, options) {
|
||||
requirePasswordConfirmation: function(callback, options, rejectCallback) {
|
||||
options = typeof options !== 'undefined' ? options : {};
|
||||
var defaults = {
|
||||
title: t('core','Authentication required'),
|
||||
|
|
@ -1775,6 +1775,8 @@ OC.PasswordConfirmation = {
|
|||
function (result, password) {
|
||||
if (result && password !== '') {
|
||||
self._confirmPassword(password, config);
|
||||
} else if (_.isFunction(rejectCallback)) {
|
||||
rejectCallback()
|
||||
}
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
35
settings/package-lock.json
generated
35
settings/package-lock.json
generated
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "settings",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
@ -3321,14 +3321,12 @@
|
|||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
|
@ -3343,20 +3341,17 @@
|
|||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
|
@ -3473,8 +3468,7 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
|
@ -3486,7 +3480,6 @@
|
|||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
|
@ -3501,7 +3494,6 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
|
@ -3509,14 +3501,12 @@
|
|||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
|
|
@ -3535,7 +3525,6 @@
|
|||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
|
@ -3616,8 +3605,7 @@
|
|||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
|
@ -3629,7 +3617,6 @@
|
|||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
|
@ -3751,7 +3738,6 @@
|
|||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
|
@ -5084,6 +5070,11 @@
|
|||
"axios": "^0.18.0"
|
||||
}
|
||||
},
|
||||
"nextcloud-password-confirmation": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/nextcloud-password-confirmation/-/nextcloud-password-confirmation-0.4.0.tgz",
|
||||
"integrity": "sha512-5RNNHP8ymxtqOEwirc4n3uv9uAga2V6wUZ7ns7mQrQQtFh/SLEX8ogSsqxquJWZ7+Jc9gVJSeRcRMLoAag966A=="
|
||||
},
|
||||
"nextcloud-vue": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/nextcloud-vue/-/nextcloud-vue-0.3.1.tgz",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "settings",
|
||||
"description": "Nextcloud settings",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"author": "John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>",
|
||||
"license": "AGPL3",
|
||||
"private": true,
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
"@babel/polyfill": "^7.0.0",
|
||||
"lodash": "^4.17.11",
|
||||
"nextcloud-axios": "^0.1.2",
|
||||
"nextcloud-password-confirmation": "^0.4.0",
|
||||
"nextcloud-vue": "^0.3.1",
|
||||
"v-tooltip": "^2.0.0-rc.33",
|
||||
"vue": "^2.5.17",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
import axios from 'nextcloud-axios'
|
||||
import confirmPassword from 'nextcloud-password-confirmation'
|
||||
|
||||
const sanitize = function(url) {
|
||||
return url.replace(/\/$/, ''); // Remove last url slash
|
||||
|
|
@ -60,35 +61,7 @@ export default {
|
|||
* @returns {Promise}
|
||||
*/
|
||||
requireAdmin() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
// TODO: migrate the OC.dialog to Vue and avoid this mess
|
||||
// wait for password confirmation
|
||||
let passwordTimeout;
|
||||
let waitForpassword = function() {
|
||||
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
||||
passwordTimeout = setTimeout(waitForpassword, 500);
|
||||
return;
|
||||
}
|
||||
clearTimeout(passwordTimeout);
|
||||
clearTimeout(promiseTimeout);
|
||||
resolve();
|
||||
};
|
||||
|
||||
// automatically reject after 5s if not resolved
|
||||
let promiseTimeout = setTimeout(() => {
|
||||
clearTimeout(passwordTimeout);
|
||||
// close dialog
|
||||
if (document.getElementsByClassName('oc-dialog-close').length>0) {
|
||||
document.getElementsByClassName('oc-dialog-close')[0].click();
|
||||
}
|
||||
OC.Notification.showTemporary(t('settings', 'You did not enter the password in time'));
|
||||
reject('Password request cancelled');
|
||||
}, 7000);
|
||||
|
||||
// request password
|
||||
OC.PasswordConfirmation.requirePasswordConfirmation();
|
||||
waitForpassword();
|
||||
});
|
||||
return confirmPassword();
|
||||
},
|
||||
get(url) {
|
||||
return axios.get(sanitize(url));
|
||||
|
|
|
|||
Loading…
Reference in a new issue