Switch to using a common directive for user setup (sign in, sign up, recover account) everywhere

This commit is contained in:
Joseph Schorr 2013-12-11 18:20:24 -05:00
parent abe6db334d
commit 9dbbd33afc
6 changed files with 105 additions and 87 deletions

View file

@ -202,12 +202,18 @@ quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'an
var planId = planService.getAndResetNotedPlan();
if (!planId) { return; }
planService.isBusinessPlan(planId, function(bus) {
if (bus) {
document.location = '/organizations/new/?plan=' + planId;
} else {
document.location = '/user?plan=' + planId;
UserService.load(function() {
if (UserService.currentUser().anonymous) {
return;
}
planService.isBusinessPlan(planId, function(bus) {
if (bus) {
document.location = '/organizations/new/?plan=' + planId;
} else {
document.location = '/user?plan=' + planId;
}
});
});
};
@ -632,6 +638,35 @@ quayApp.directive('repoCircle', function () {
});
quayApp.directive('userSetup', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/user-setup.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'redirectUrl': '=redirectUrl',
'signInStarted': '&signInStarted',
'signedIn': '&signedIn'
},
controller: function($scope, $location, $timeout, Restangular, KeyService, UserService) {
$scope.sendRecovery = function() {
var signinPost = Restangular.one('recovery');
signinPost.customPOST($scope.recovery).then(function() {
$scope.invalidEmail = false;
$scope.sent = true;
}, function(result) {
$scope.invalidEmail = true;
$scope.sent = false;
});
};
}
};
return directiveDefinitionObject;
});
quayApp.directive('signinForm', function () {
var directiveDefinitionObject = {
priority: 0,