Skip to content
Snippets Groups Projects
Unverified Commit 237c70d3 authored by Morris Jobke's avatar Morris Jobke Committed by GitHub
Browse files

Merge pull request #12409 from nextcloud/admin-vue-approval-fix

Use nextcloud-password-confirmation
parents 859dd1e7 85c708c3
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"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",
......
{
"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",
......
/*
/**
* @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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment