summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-10-25 13:05:13 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-11-18 12:10:50 +0100
commit2fd2e45e428b24f16b7724b7a31d660ba67d2ef1 (patch)
treec6e77f9f796e25d38bef8cf401d1945429becd45 /settings/js
parent410e0fc28f25835c4b10e31066b641387cb53391 (diff)
downloadnextcloud-server-2fd2e45e428b24f16b7724b7a31d660ba67d2ef1.tar.gz
nextcloud-server-2fd2e45e428b24f16b7724b7a31d660ba67d2ef1.zip
Require password confirmation for user management
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/users/users.js68
1 files changed, 54 insertions, 14 deletions
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index 3a357c0e9c4..7f23f2dad3f 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -353,6 +353,14 @@ var UserList = {
$userListBody.on('click', '.delete', function () {
// Call function for handling delete/undo
var uid = UserList.getUID(this);
+
+ if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+ OC.PasswordConfirmation.requirePasswordConfirmation(function() {
+ UserDeleteHandler.mark(uid);
+ });
+ return;
+ }
+
UserDeleteHandler.mark(uid);
});
@@ -405,6 +413,11 @@ var UserList = {
},
applyGroupSelect: function (element, user, checked) {
+ if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+ OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.applySubadminSelect, this, arguments));
+ return;
+ }
+
var $element = $(element);
var checkHandler = null;
@@ -467,6 +480,11 @@ var UserList = {
},
applySubadminSelect: function (element, user, checked) {
+ if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+ OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.applySubadminSelect, this, arguments));
+ return;
+ }
+
var $element = $(element);
var checkHandler = function (group) {
if (group === 'admin') {
@@ -478,7 +496,10 @@ var UserList = {
username: user,
group: group
},
- function () {
+ function (response) {
+ if (response.data.message) {
+ OC.Notification.show(response.data.message);
+ }
}
);
};
@@ -635,6 +656,27 @@ $(document).ready(function () {
// TODO: move other init calls inside of initialize
UserList.initialize($('#userlist'));
+ var _submitPasswordChange = function(uid, password, recoveryPasswordVal) {
+ if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+ OC.PasswordConfirmation.requirePasswordConfirmation(function() {
+ _submitPasswordChange(uid, password, recoveryPasswordVal);
+ });
+ return;
+ }
+
+ $.post(
+ OC.generateUrl('/settings/users/changepassword'),
+ {username: uid, password: password, recoveryPassword: recoveryPasswordVal},
+ function (result) {
+ if (result.status === 'success') {
+ OC.Notification.showTemporary(t('admin', 'Password successfully changed'));
+ } else {
+ OC.Notification.showTemporary(t('admin', result.data.message));
+ }
+ }
+ );
+ };
+
$userListBody.on('click', '.password', function (event) {
event.stopPropagation();
@@ -657,17 +699,7 @@ $(document).ready(function () {
if (event.keyCode === 13) {
if ($(this).val().length > 0) {
var recoveryPasswordVal = $('input:password[id="recoveryPassword"]').val();
- $.post(
- OC.generateUrl('/settings/users/changepassword'),
- {username: uid, password: $(this).val(), recoveryPassword: recoveryPasswordVal},
- function (result) {
- if (result.status === 'success') {
- OC.Notification.showTemporary(t('admin', 'Password successfully changed'));
- } else {
- OC.Notification.showTemporary(t('admin', result.data.message));
- }
- }
- );
+ _submitPasswordChange(uid, $(this).val(), recoveryPasswordVal);
$input.blur();
} else {
$input.blur();
@@ -796,7 +828,14 @@ $(document).ready(function () {
});
UserList._updateGroupListLabel($('#newuser .groups'), []);
- $('#newuser').submit(function (event) {
+ var _submitNewUserForm = function (event) {
+ if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+ OC.PasswordConfirmation.requirePasswordConfirmation(function() {
+ _submitNewUserForm(event);
+ });
+ return;
+ }
+
event.preventDefault();
var username = $('#newusername').val();
var password = $('#newuserpassword').val();
@@ -866,7 +905,8 @@ $(document).ready(function () {
$('#newuser').get(0).reset();
});
});
- });
+ }
+ $('#newuser').submit(_submitNewUserForm);
if ($('#CheckboxStorageLocation').is(':checked')) {
$("#userlist .storageLocation").show();