Add superuser abilities: create user, show logs. Also fix the super users UI to show the user drop down and make all superuser API calls require fresh login
This commit is contained in:
parent
039d53ea6c
commit
d9c7e92637
6 changed files with 225 additions and 29 deletions
|
@ -2696,6 +2696,14 @@ function SuperUserAdminCtrl($scope, ApiService, Features, UserService) {
|
|||
// Monitor any user changes and place the current user into the scope.
|
||||
UserService.updateUserIn($scope);
|
||||
|
||||
$scope.logsCounter = 0;
|
||||
$scope.newUser = {};
|
||||
$scope.createdUsers = [];
|
||||
|
||||
$scope.loadLogs = function() {
|
||||
$scope.logsCounter++;
|
||||
};
|
||||
|
||||
$scope.loadUsers = function() {
|
||||
if ($scope.users) {
|
||||
return;
|
||||
|
@ -2707,6 +2715,7 @@ function SuperUserAdminCtrl($scope, ApiService, Features, UserService) {
|
|||
$scope.loadUsersInternal = function() {
|
||||
ApiService.listAllUsers().then(function(resp) {
|
||||
$scope.users = resp['users'];
|
||||
$scope.showInterface = true;
|
||||
}, function(resp) {
|
||||
$scope.users = [];
|
||||
$scope.usersError = resp['data']['message'] || resp['data']['error_description'];
|
||||
|
@ -2718,6 +2727,19 @@ function SuperUserAdminCtrl($scope, ApiService, Features, UserService) {
|
|||
$('#changePasswordModal').modal({});
|
||||
};
|
||||
|
||||
$scope.createUser = function() {
|
||||
$scope.creatingUser = true;
|
||||
var errorHandler = ApiService.errorDisplay('Cannot create user', function() {
|
||||
$scope.creatingUser = false;
|
||||
});
|
||||
|
||||
ApiService.createInstallUser($scope.newUser, null).then(function(resp) {
|
||||
$scope.creatingUser = false;
|
||||
$scope.newUser = {};
|
||||
$scope.createdUsers.push(resp);
|
||||
}, errorHandler)
|
||||
};
|
||||
|
||||
$scope.showDeleteUser = function(user) {
|
||||
if (user.username == UserService.currentUser().username) {
|
||||
bootbox.dialog({
|
||||
|
@ -2765,6 +2787,26 @@ function SuperUserAdminCtrl($scope, ApiService, Features, UserService) {
|
|||
}, ApiService.errorDisplay('Cannot delete user'));
|
||||
};
|
||||
|
||||
$scope.sendRecoveryEmail = function(user) {
|
||||
var params = {
|
||||
'username': user.username
|
||||
};
|
||||
|
||||
ApiService.sendInstallUserRecoveryEmail(null, params).then(function(resp) {
|
||||
bootbox.dialog({
|
||||
"message": "A recovery email has been sent to " + resp['email'],
|
||||
"title": "Recovery email sent",
|
||||
"buttons": {
|
||||
"close": {
|
||||
"label": "Close",
|
||||
"className": "btn-primary"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, ApiService.errorDisplay('Cannot send recovery email'))
|
||||
};
|
||||
|
||||
$scope.loadUsers();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue