- Better error messages for sign up

- Show a throbber while working on sign up
- Have the front page redirect to the repositories view when logged in
This commit is contained in:
Joseph Schorr 2013-10-01 22:13:43 -04:00
parent 211fd6bcd7
commit 31914da4ca
4 changed files with 31 additions and 4 deletions

View file

@ -100,18 +100,29 @@ function RepoListCtrl($scope, Restangular) {
function LandingCtrl($scope, $timeout, Restangular, UserService) {
$('.form-signup').popover();
$('.spin').spin();
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
$scope.user = currentUser;
if (currentUser && !currentUser.anonymous) {
document.location = '/#/repository';
}
}, true);
$scope.awaitingConfirmation = false;
$scope.registering = false;
$scope.register = function() {
$('.form-signup').popover('hide');
$scope.registering = true;
var newUserPost = Restangular.one('user/');
newUserPost.customPOST($scope.newUser).then(function() {
$scope.awaitingConfirmation = true;
$scope.registering = false;
}, function(result) {
console.log("Displaying error message.");
$scope.registering = false;
$scope.registerError = result.data.message;
$timeout(function() {
$('.form-signup').popover('show');

View file

@ -9,13 +9,16 @@
<div class="signup-container">
<div ng-show="user.anonymous">
<form class="form-signup" name="signupForm" ng-submit="register()" data-trigger="manual" data-content="{{ registerError }}" data-placement="left" ng-show="!awaitingConfirmation">
<form class="form-signup" name="signupForm" ng-submit="register()" data-trigger="manual" data-content="{{ registerError }}" data-placement="left" ng-show="!awaitingConfirmation && !registering">
<input type="text" class="form-control" placeholder="Create a username" name="username" ng-model="newUser.username" autofocus required>
<input type="email" class="form-control" placeholder="Email address" ng-model="newUser.email" required>
<input type="password" class="form-control" placeholder="Create a password" ng-model="newUser.password" required>
<input type="password" class="form-control" placeholder="Verify your password" ng-model="newUser.repeatePassword" match="newUser.password" required>
<button class="btn btn-lg btn-primary btn-block" ng-disabled="signupForm.$invalid" type="submit">Get Started!</button>
</form>
<div ng-show="registering" style="text-align: center">
<span class="spin" color="#fff" style="display: inline-block"></span>
</div>
<div ng-show="awaitingConfirmation">
<div class="sub-message">Thank you for registering! We have sent you an activation email. You must <b>verify your email address</b> before you can continue.</div>
</div>