diff --git a/controllers/user.js b/controllers/user.js index 2315602bc3..bc46b8553f 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -189,9 +189,7 @@ exports.checkUniqueUsername = function(req, res) { */ exports.checkUniqueEmail = function(req, res) { - console.log(req.params.email); User.count({'email': decodeURIComponent(req.params.email).toLowerCase()}, function (err, data) { - console.log(User.findOne({'email': decodeURIComponent(req.params.email)})); if (data == 1) { return res.send(true); } else { diff --git a/public/js/main.js b/public/js/main.js index 26983d7c9a..32785360c7 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -48,6 +48,7 @@ profileValidation.controller('profileValidationController', ['$scope', '$http', $http.get('/account/api').success(function(data) { $scope.user = data.user; $scope.user.profile.username = $scope.user.profile.username.toLowerCase(); + $scope.storedUsername = $scope.user.profile.username; $scope.user.email = $scope.user.email.toLowerCase(); $scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle.toLowerCase(); }); @@ -93,7 +94,6 @@ profileValidation.directive('uniqueEmail', function($http) { element.bind("keyup", function (event) { ngModel.$setValidity('unique', true); if (element.val()) { - console.log(encodeURIComponent(element.val())); $http.get("/api/checkUniqueEmail/" + encodeURIComponent(element.val())).success(function (data) { if (data) { ngModel.$setValidity('unique', false); diff --git a/views/account/email-signup.jade b/views/account/email-signup.jade index 765eed26da..356807d382 100644 --- a/views/account/email-signup.jade +++ b/views/account/email-signup.jade @@ -5,19 +5,28 @@ block content form.form-horizontal(method='POST', action='/email-signup', name="signupForm", novalidate="novalidate") input(type='hidden', name='_csrf', value=_csrf) .form-group - .col-sm-6.col-sm-offset-3 - input.form-control(type='email', ng-model='email', ng-keypress='', name='email', id='email', placeholder='email', autofocus, required, autocomplete="off", unique-email='') - .col-sm-6.col-sm-offset-3(ng-show="signupForm.email.$error.unique && !signupForm.email.$pristine") - alert(type='danger') - span.ion-close-circled - | This email is taken. + h3 + .col-sm-6.col-sm-offset-3 + input.form-control(type='email', ng-model='email', ng-keypress='', name='email', id='email', placeholder='email', autofocus, required, autocomplete="off", unique-email='') + .col-sm-3(ng-show="signupForm.email.$error.unique && !signupForm.email.$pristine") + alert(type='danger') + span.ion-close-circled + | This email is taken. .form-group .col-sm-6.col-sm-offset-3 - input.form-control(type='text', name='username', ng-keypress='', autocomplete="off", id='username', placeholder='username', ng-model='username', unique-username='', required) + input.form-control(type='text', name='username', ng-keypress='', autocomplete="off", id='username', placeholder='username', ng-model='username', unique-username='', required, ng-minlength=5, ng-maxlength=20) .col-sm-6.col-sm-offset-3(ng-show="signupForm.username.$error.unique && !signupForm.username.$pristine") alert(type='danger') span.ion-close-circled | This username is taken. + .col-sm-6.col-sm-offset-3(ng-show="signupForm.username.$error.minlength && !signupForm.username.$pristine") + alert(type='danger') + span.ion-close-circled + | Usernames must be at least 5 characters. + .col-sm-6.col-sm-offset-3(ng-show="signupForm.username.$error.maxlength && !signupForm.username.$pristine") + alert(type='danger') + span.ion-close-circled + | Usernames must be 20 characters or less. .form-group .col-sm-6.col-sm-offset-3 input.form-control(type='password', ng-model='password', name='password', id='password', placeholder='password', required) diff --git a/views/account/profile.jade b/views/account/profile.jade index 0fb25cd99e..41c7102c36 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -13,7 +13,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='name') Name * .col-sm-4 - input.form-control(type='text', ng-keyup='keyPress()', placeholder='Name', name='name', ng-model='user.profile.name', ng-minlength='3', ng-maxlength='50', required='required', id='name') + input.form-control(type='text', placeholder='Name', name='name', ng-model='user.profile.name', ng-minlength='3', ng-maxlength='50', required='required', id='name') .col-sm-4.col-sm-offset-5(ng-show="profileForm.name.$invalid && !profileForm.name.$pristine && profileForm.name.$error.required") alert(type='danger') span.ion-close-circled @@ -30,7 +30,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (path to public profile) * .col-sm-4 - input.form-control(type='text', placeholder='username' name='username', id='username', ng-model='user.profile.username', required='required', ng-minlength='5', ng-maxlength='20') + input.form-control(type='text', placeholder='username' name='username', id='username', ng-model='user.profile.username', required='required', ng-minlength='5', ng-maxlength='20', ng-keypress='', unique-username='') .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.required && !profileForm.username.$pristine") alert(type='danger') span.ion-close-circled @@ -43,6 +43,10 @@ block content alert(type='danger') span.ion-close-circled | Your username must be fewer than 15 characters. + .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.unique && !profileForm.username.$pristine") + alert(type='danger') + span.ion-close-circled + | This username is taken. .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Email *