Option to generate multiple new passwords (closes #2350)
This commit is contained in:
parent
2753af3585
commit
42f723f3cb
@ -415,11 +415,13 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
.controller('UserListCtrl', [
|
||||
'$scope',
|
||||
'$state',
|
||||
'$http',
|
||||
'ngDialog',
|
||||
'UserForm',
|
||||
'User',
|
||||
'Group',
|
||||
function($scope, $state, ngDialog, UserForm, User, Group) {
|
||||
'PasswordGenerator',
|
||||
function($scope, $state, $http, ngDialog, UserForm, User, Group, PasswordGenerator) {
|
||||
User.bindAll({}, $scope, 'users');
|
||||
Group.bindAll({where: {id: {'>': 1}}}, $scope, 'groups');
|
||||
$scope.alert = {};
|
||||
@ -520,6 +522,22 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
$scope.isSelectMode = false;
|
||||
$scope.uncheckAll();
|
||||
};
|
||||
// generate new passwords
|
||||
$scope.generateNewPasswordsMultiple = function () {
|
||||
angular.forEach($scope.users, function (user) {
|
||||
if (user.selected) {
|
||||
var newPassword = PasswordGenerator.generate();
|
||||
user.default_password = newPassword;
|
||||
User.save(user);
|
||||
$http.post(
|
||||
'/rest/users/user/' + user.id + '/reset_password/',
|
||||
{'password': newPassword}
|
||||
);
|
||||
}
|
||||
});
|
||||
$scope.isSelectMode = false;
|
||||
$scope.uncheckAll();
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
|
@ -87,6 +87,7 @@
|
||||
<option value="delete" translate>Delete</option>
|
||||
<option value="addGroup" translate>Add group</option>
|
||||
<option value="removeGroup" translate>Remove group</option>
|
||||
<option value="generatePasswords" translate>Generate new passwords</option>
|
||||
</select>
|
||||
<!-- delete button -->
|
||||
<a ng-show="selectedAction == 'delete'"
|
||||
@ -113,6 +114,12 @@
|
||||
<i class="fa fa-minus fa-lg"></i>
|
||||
<translate>Remove group</translate>
|
||||
</a>
|
||||
<!-- generate new password button -->
|
||||
<a ng-show="selectedAction == 'generatePasswords'" class="btn btn-default"
|
||||
ng-click="generateNewPasswordsMultiple()">
|
||||
<i class="fa fa-magic"></i>
|
||||
<translate>Generate new passwords</translate>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user