mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(uac): add multi user management and UAC (#647)
This commit is contained in:
parent
f28f223624
commit
80d50378c5
91 changed files with 3973 additions and 866 deletions
85
app/components/user/userController.js
Normal file
85
app/components/user/userController.js
Normal file
|
@ -0,0 +1,85 @@
|
|||
angular.module('user', [])
|
||||
.controller('UserController', ['$scope', '$state', '$stateParams', 'UserService', 'ModalService', 'Messages',
|
||||
function ($scope, $state, $stateParams, UserService, ModalService, Messages) {
|
||||
|
||||
$scope.state = {
|
||||
updatePasswordError: '',
|
||||
};
|
||||
|
||||
$scope.formValues = {
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
};
|
||||
|
||||
$scope.deleteUser = function() {
|
||||
ModalService.confirmDeletion(
|
||||
'Do you want to delete this user? This user will not be able to login into Portainer anymore.',
|
||||
function onConfirm(confirmed) {
|
||||
if(!confirmed) { return; }
|
||||
deleteUser();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
$scope.updatePermissions = function() {
|
||||
$('#loadingViewSpinner').show();
|
||||
UserService.updateUser($scope.user.Id, undefined, $scope.user.RoleId)
|
||||
.then(function success(data) {
|
||||
var newRole = $scope.user.RoleId === 1 ? 'administrator' : 'user';
|
||||
Messages.send('Permissions successfully updated', $scope.user.Username + ' is now ' + newRole);
|
||||
$state.reload();
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Messages.error("Failure", err, 'Unable to update user permissions');
|
||||
})
|
||||
.finally(function final() {
|
||||
$('#loadingViewSpinner').hide();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updatePassword = function() {
|
||||
$('#loadingViewSpinner').show();
|
||||
UserService.updateUser($scope.user.Id, $scope.formValues.newPassword, undefined)
|
||||
.then(function success(data) {
|
||||
Messages.send('Password successfully updated');
|
||||
$state.reload();
|
||||
})
|
||||
.catch(function error(err) {
|
||||
$scope.state.updatePasswordError = 'Unable to update password';
|
||||
})
|
||||
.finally(function final() {
|
||||
$('#loadingViewSpinner').hide();
|
||||
});
|
||||
};
|
||||
|
||||
function deleteUser() {
|
||||
$('#loadingViewSpinner').show();
|
||||
UserService.deleteUser($scope.user.Id)
|
||||
.then(function success(data) {
|
||||
Messages.send('User successfully deleted', $scope.user.Username);
|
||||
$state.go('users');
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Messages.error("Failure", err, 'Unable to remove user');
|
||||
})
|
||||
.finally(function final() {
|
||||
$('#loadingViewSpinner').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function getUser() {
|
||||
$('#loadingViewSpinner').show();
|
||||
UserService.user($stateParams.id)
|
||||
.then(function success(data) {
|
||||
$scope.user = new UserViewModel(data);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Messages.error("Failure", err, 'Unable to retrieve user information');
|
||||
})
|
||||
.finally(function final() {
|
||||
$('#loadingViewSpinner').hide();
|
||||
});
|
||||
}
|
||||
|
||||
getUser();
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue