This commit is contained in:
Joseph Schorr 2013-10-10 20:48:33 -04:00
commit 2ae4dbd9fa
17 changed files with 300 additions and 65 deletions

View file

@ -130,7 +130,7 @@ function RepoListCtrl($scope, Restangular, UserService) {
});
}
function LandingCtrl($scope, $timeout, Restangular, UserService) {
function LandingCtrl($scope, $timeout, Restangular, UserService, KeyService) {
$('.form-signup').popover();
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
@ -141,6 +141,13 @@ function LandingCtrl($scope, $timeout, Restangular, UserService) {
$scope.user = currentUser;
}, true);
angulartics.waitForVendorApi(mixpanel, 500, function(loadedMixpanel) {
var mixpanelId = loadedMixpanel.get_distinct_id();
$scope.github_state_clause = '&state=' + mixpanelId;
});
$scope.githubClientId = KeyService.githubClientId;
$scope.awaitingConfirmation = false;
$scope.registering = false;
@ -162,12 +169,6 @@ function LandingCtrl($scope, $timeout, Restangular, UserService) {
$scope.registering = false;
mixpanel.alias($scope.newUser.username);
mixpanel.people.set_once({
'$email': $scope.newUser.email,
'$username': $scope.newUser.username,
'$created': new Date(),
'verified': false
});
}, function(result) {
$scope.registering = false;
$scope.registerError = result.data.message;
@ -468,9 +469,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);
@ -557,4 +562,33 @@ 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;
// Reset the form
$scope.user.password = '';
$scope.user.repeatPassword = '';
$scope.changePasswordForm.$setPristine();
UserService.load();
}, function(result) {
$scope.updatingUser = false;
$scope.changePasswordError = result.data.message;
$timeout(function() {
$('.form-change-pw').popover('show');
});
});
};
}