Start on organization conversion. Note that this does not yet move over the user's plan to an org plan

This commit is contained in:
Joseph Schorr 2013-11-07 16:33:56 -05:00
parent a7415ef4d3
commit 3f2d51651e
5 changed files with 241 additions and 1 deletions

View file

@ -690,7 +690,7 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
}
function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService, KeyService, $routeParams) {
function UserAdminCtrl($scope, $timeout, $location, Restangular, PlanService, UserService, KeyService, $routeParams) {
$scope.$watch(function () { return UserService.currentUser(); }, function (currentUser) {
$scope.askForPassword = currentUser.askForPassword;
if (!currentUser.anonymous) {
@ -704,12 +704,48 @@ function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService,
return $routeParams['plan'];
};
if ($routeParams['migrate']) {
$('#migrateTab').tab('show')
}
$scope.loading = true;
$scope.updatingUser = false;
$scope.changePasswordSuccess = false;
$scope.convertStep = 0;
$('.form-change-pw').popover();
$scope.showConvertForm = function() {
$scope.convertStep = 1;
};
$scope.convertToOrg = function() {
$('#reallyconvertModal').modal({});
};
$scope.reallyConvert = function() {
$scope.loading = true;
var data = {
'adminUser': $scope.org.adminUser,
'adminPassword': $scope.org.adminPassword
};
var convertAccount = Restangular.one('user/convert');
convertAccount.customPOST(data).then(function(resp) {
UserService.load();
$location.path('/');
}, function(resp) {
$scope.loading = false;
if (resp.data.reason == 'invaliduser') {
$('#invalidadminModal').modal({});
} else {
$('#cannotconvertModal').modal({});
}
});
};
$scope.changePassword = function() {
$('.form-change-pw').popover('hide');
$scope.updatingUser = true;