Use new ownership transfer route

This commit is contained in:
Johannes Zellner
2021-01-15 14:28:52 +01:00
parent 32d7b2fe34
commit 1b09a80caa
2 changed files with 14 additions and 25 deletions

View File

@@ -68,39 +68,19 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
submit: function () {
$scope.transferOwnership.busy = true;
// first grant other user owner role, then remove it from existing
var data = {
id: $scope.transferOwnership.userInfo.id,
role: 'owner'
};
Client.changeOwnership($scope.transferOwnership.userInfo.id, function (error) {
$scope.transferOwnership.busy = false;
Client.updateUser(data, function (error) {
if (error) {
$scope.transferOwnership.busy = false;
$scope.transferOwnership.error = error.message;
console.error('Unable to change user role:', error);
return;
}
data = {
id: $scope.userInfo.id,
role: 'user'
};
$('#transferOwnershipModal').modal('hide');
Client.updateUser(data, function (error) {
$scope.transferOwnership.busy = false;
if (error) {
$scope.transferOwnership.error = error.message;
console.error('Unable to change user role:', error);
return;
}
$('#transferOwnershipModal').modal('hide');
// current user was demoted, reload to refresh UI state
window.location.reload();
});
// current user was demoted, reload to refresh UI state
window.location.reload();
});
}
};