diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2021-04-24 06:28:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-24 06:28:08 +0300 |
commit | 6227cb05197d4dfd0aa0d695eb665b6c1ef455d6 (patch) | |
tree | 3d100156c4d2c0effc981ebb8c041a840ee76ac1 /plugins/CorePluginsAdmin/angularjs | |
parent | d1422903bb698fac80e1ab0590d62c63dd6574bf (diff) |
Require password confirmation for more plugin operations. (#17345)
* Require password confirmation for more plugin operations.
* renormalize
* add optional password confirmation to CorePluginsAdmin.setSystemSettings
* Add developer changelog entry.
* ask for password confirmation when saving plugin settings and use onOpenEnd materializecss modal event handler instead of ready since ready no longer exists in used version
* Fix redirectTo==referrer for other plugin actions that now have password confirmation.
* fix build
* try fixing build again
Diffstat (limited to 'plugins/CorePluginsAdmin/angularjs')
3 files changed, 53 insertions, 3 deletions
diff --git a/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.controller.js b/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.controller.js index 01bb921004..5806abe3a3 100644 --- a/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.controller.js +++ b/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.controller.js @@ -7,15 +7,17 @@ (function () { angular.module('piwikApp').controller('PluginSettingsController', PluginSettingsController); - PluginSettingsController.$inject = ['$scope', 'piwikApi']; + PluginSettingsController.$inject = ['$scope', 'piwikApi', '$element']; - function PluginSettingsController($scope, piwikApi) { + function PluginSettingsController($scope, piwikApi, $element) { // remember to keep controller very simple. Create a service/factory (model) if needed var self = this; this.isLoading = true; this.isSaving = {}; + this.passwordConfirmation = ''; + this.settingsToSave = null; var apiMethod = 'CorePluginsAdmin.getUserSettings'; @@ -34,6 +36,27 @@ var apiMethod = 'CorePluginsAdmin.setUserSettings'; if ($scope.mode === 'admin') { apiMethod = 'CorePluginsAdmin.setSystemSettings'; + + if (!this.passwordConfirmation) { + this.settingsToSave = settings; + + function onEnter(event){ + var keycode = (event.keyCode ? event.keyCode : event.which); + if (keycode == '13'){ + $element.find('.confirm-password-modal').modal('close'); + self.save(); + } + } + + $element.find('.confirm-password-modal').modal({ dismissible: false, onOpenEnd: function () { + $('.modal.open #currentUserPassword').focus(); + $('.modal.open #currentUserPassword').off('keypress').keypress(onEnter); + }}).modal('open'); + + return; + } else { + settings = this.settingsToSave; + } } this.isSaving[settings.pluginName] = true; @@ -56,7 +79,7 @@ }); }); - piwikApi.post({method: apiMethod}, {settingValues: values}).then(function (success) { + piwikApi.post({method: apiMethod}, {settingValues: values, passwordConfirmation: this.passwordConfirmation}).then(function (success) { self.isSaving[settings.pluginName] = false; var UI = require('piwik/UI'); @@ -69,6 +92,9 @@ }, function () { self.isSaving[settings.pluginName] = false; }); + + this.passwordConfirmation = ''; + this.settingsToSave = null; }; } })(); diff --git a/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.html b/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.html index 6f77711ecc..4e082e94bf 100644 --- a/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.html +++ b/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.html @@ -22,4 +22,20 @@ </div> + <div class="confirm-password-modal modal"> + <div class="modal-content"> + <h2>{{:: 'UsersManager_ConfirmWithPassword'|translate }}</h2> + + <div piwik-field uicontrol="password" name="currentUserPassword" autocomplete="off" + ng-model="pluginSettings.passwordConfirmation" + full-width="true" + title="{{:: 'UsersManager_YourCurrentPassword'|translate }}" + value=""> + </div> + </div> + <div class="modal-footer"> + <a href="" class="modal-action modal-close btn" ng-disabled="!pluginSettings.passwordConfirmation" ng-click="pluginSettings.save()">{{:: 'General_Yes'|translate }}</a> + <a href="" class="modal-action modal-close modal-no">{{:: 'General_No'|translate }}</a> + </div> + </div> </div> diff --git a/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.less b/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.less index 3b86a59aba..affc515e84 100644 --- a/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.less +++ b/plugins/CorePluginsAdmin/angularjs/plugin-settings/plugin-settings.directive.less @@ -2,6 +2,14 @@ textarea { display: block; } + + .confirm-password-modal { + .modal-no { + margin-left: 1em; + margin-right: 1em; + margin-top: 1em; + } + } } .pluginsSettingsSubmit { margin-top: 30px; |