Add a form for changing the password and prompt the user to do so when there is no password on the account.

This commit is contained in:
yackob03 2013-10-10 13:44:34 -04:00
parent e016d5822f
commit 16ee147eae
7 changed files with 98 additions and 10 deletions

View file

@ -456,9 +456,13 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
});
}
function UserAdminCtrl($scope, Restangular, PlanService, KeyService, $routeParams) {
function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService, KeyService, $routeParams) {
$scope.plans = PlanService.planList();
$scope.$watch(function () { return UserService.currentUser(); }, function (currentUser) {
$scope.askForPassword = currentUser.askForPassword;
}, true);
var subscribedToPlan = function(sub) {
$scope.subscription = sub;
$scope.subscribedPlan = PlanService.getPlan(sub.plan);
@ -545,4 +549,28 @@ function UserAdminCtrl($scope, Restangular, PlanService, KeyService, $routeParam
$scope.subscribe(requested);
}
}
$scope.updatingUser = false;
$scope.changePasswordSuccess = false;
$('.form-change-pw').popover();
$scope.changePassword = function() {
$('.form-change-pw').popover('hide');
$scope.updatingUser = true;
$scope.changePasswordSuccess = false;
var changePasswordPost = Restangular.one('user/');
changePasswordPost.customPUT($scope.user).then(function() {
$scope.updatingUser = false;
$scope.changePasswordSuccess = true;
UserService.load();
}, function(result) {
$scope.updatingUser = false;
$scope.changePasswordError = result.data.message;
$timeout(function() {
$('.form-change-pw').popover('show');
});
});
};
}