Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sudo mode to enabling and disabling apps #2509

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions settings/ajax/disableapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();

$lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
$l = \OC::$server->getL10N('core');
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
exit();
}

if (!array_key_exists('appid', $_POST)) {
OC_JSON::error();
exit;
Expand Down
7 changes: 7 additions & 0 deletions settings/ajax/enableapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
OC_JSON::checkAdminUser();
OCP\JSON::callCheck();

$lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
$l = \OC::$server->getL10N('core');
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
exit();
}

$groups = isset($_POST['groups']) ? (array)$_POST['groups'] : null;

try {
Expand Down
7 changes: 7 additions & 0 deletions settings/ajax/installapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();

$lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
$l = \OC::$server->getL10N('core');
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
exit();
}

if (!array_key_exists('appid', $_POST)) {
OC_JSON::error();
exit;
Expand Down
7 changes: 7 additions & 0 deletions settings/ajax/uninstallapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();

$lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
$l = \OC::$server->getL10N('core');
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
exit();
}

if (!array_key_exists('appid', $_POST)) {
OC_JSON::error();
exit;
Expand Down
10 changes: 10 additions & 0 deletions settings/js/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ OC.Settings.Apps = OC.Settings.Apps || {
},

enableApp:function(appId, active, element, groups) {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.enableApp, this, appId, active, element, groups));
return;
}

var self = this;
OC.Settings.Apps.hideErrorMessage(appId);
groups = groups || [];
Expand Down Expand Up @@ -395,6 +400,11 @@ OC.Settings.Apps = OC.Settings.Apps || {
},

uninstallApp:function(appId, element) {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.uninstallApp, this, appId, element));
return;
}

OC.Settings.Apps.hideErrorMessage(appId);
element.val(t('settings','Uninstalling ....'));
$.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appId},function(result) {
Expand Down