|
|
@ -12,6 +12,22 @@ |
|
|
|
|
|
|
|
var lilikAddUserApp = angular.module('lilikAddUserApp', []); |
|
|
|
|
|
|
|
lilikAddUserApp.filter('excludeKey', function() { |
|
|
|
return function(input, search) { |
|
|
|
if (!input) return input; |
|
|
|
if (!search) return input; |
|
|
|
var excluded_key = ('' + search); |
|
|
|
var result = {}; |
|
|
|
angular.forEach(input, function(value, key) { |
|
|
|
var actual_key = ('' + key); |
|
|
|
if (actual_key != excluded_key) { |
|
|
|
result[key] = value; |
|
|
|
} |
|
|
|
}); |
|
|
|
return result; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
lilikAddUserApp.controller('AddUserController', function AddUserController($scope, $http) { |
|
|
|
// Initialize scope variable
|
|
|
|
$scope.showLoginForm = true; |
|
|
@ -19,11 +35,16 @@ |
|
|
|
$scope.showConfirmForm = false; |
|
|
|
$scope.startConfirm = false; |
|
|
|
$scope.creationPending = false; |
|
|
|
$scope.newExtraGroups = []; |
|
|
|
|
|
|
|
$scope.typingUser = function () { |
|
|
|
$scope.newUid = $scope.newUid.toLowerCase().replace(' ', '-'); |
|
|
|
$scope.newCn = $scope.newUid.replace('-',' ').replace(/(^\w|\s\w)/g, m => m.toUpperCase()); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
$scope.notPrincipal = function (group) { |
|
|
|
return group.key !== $scope.newGroup; |
|
|
|
} |
|
|
|
|
|
|
|
// Try to login and download groups
|
|
|
|
$scope.getGroups = function () { |
|
|
@ -52,7 +73,8 @@ |
|
|
|
$scope.confirmNewUser = function () { |
|
|
|
newEntry = { |
|
|
|
"cn": $scope.newCn, |
|
|
|
"sn": $scope.newSn |
|
|
|
"sn": $scope.newSn, |
|
|
|
"memberOf": $scope.newExtraGroups |
|
|
|
}; |
|
|
|
$http.post('../user_backend/group/'+$scope.newGroup+'/create/'+$scope.newUid, |
|
|
|
{ |
|
|
@ -67,7 +89,7 @@ |
|
|
|
} else { |
|
|
|
$scope.createError = result.reason; |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// Clear old user scope variable and start creating another
|
|
|
@ -77,6 +99,7 @@ |
|
|
|
delete $scope.newUid; |
|
|
|
delete $scope.newCn; |
|
|
|
delete $scope.newSn; |
|
|
|
$scope.newExtraGroups = []; |
|
|
|
$scope.startConfirm = false; |
|
|
|
}; |
|
|
|
|
|
|
|