This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/signup-form.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* An element which displays the sign up form.
*/
angular.module('quay').directive('signupForm', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/signup-form.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'inviteCode': '=inviteCode',
'hideRegisteredMessage': '@hideRegisteredMessage',
'userRegistered': '&userRegistered'
},
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, Config, UIService) {
$('.form-signup').popover();
$scope.awaitingConfirmation = false;
$scope.registering = false;
$scope.register = function() {
UIService.hidePopover('#signupButton');
$scope.registering = true;
if ($scope.inviteCode) {
$scope.newUser['invite_code'] = $scope.inviteCode;
}
ApiService.createNewUser($scope.newUser).then(function(resp) {
$scope.registering = false;
$scope.awaitingConfirmation = !!resp['awaiting_verification'];
if (Config.MIXPANEL_KEY) {
mixpanel.alias($scope.newUser.username);
}
if (!$scope.awaitingConfirmation) {
document.location = '/';
}
$scope.userRegistered({'username': $scope.newUser.username});
}, function(result) {
$scope.registering = false;
UIService.showFormError('#signupButton', result);
});
};
}
};
return directiveDefinitionObject;
});