Merge pull request #2382 from FinnStutzenstein/2350

Option to generate multiple new passwords (closes #2350)
This commit is contained in:
Norman Jäckel 2016-09-17 12:05:30 +02:00 committed by GitHub
commit 7998df03a3
2 changed files with 26 additions and 1 deletions

View File

@ -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();
};
}
])

View File

@ -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>