Existing username check now working, error box showing and hiding properly, UI tweaks
This commit is contained in:
@ -191,9 +191,11 @@ exports.checkUniqueUsername = function(req, res) {
|
|||||||
exports.checkExistingUsername = function(req, res) {
|
exports.checkExistingUsername = function(req, res) {
|
||||||
User.count({'profile.username': req.params.username.toLowerCase()}, function (err, data) {
|
User.count({'profile.username': req.params.username.toLowerCase()}, function (err, data) {
|
||||||
if (data == 1) {
|
if (data == 1) {
|
||||||
return res.send(false);
|
debug('sending false back')
|
||||||
} else {
|
|
||||||
return res.send(true);
|
return res.send(true);
|
||||||
|
} else {
|
||||||
|
debug('sending true back')
|
||||||
|
return res.send(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -96,7 +96,7 @@ profileValidation.controller('profileValidationController', ['$scope', '$http',
|
|||||||
|
|
||||||
profileValidation.controller('pairedWithController', ['$scope',
|
profileValidation.controller('pairedWithController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
$scope.existingUser = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
@ -152,16 +152,16 @@ profileValidation.directive('existingUsername', function($http) {
|
|||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function (scope, element, attrs, ngModel) {
|
link: function (scope, element, attrs, ngModel) {
|
||||||
element.bind("keyup", function (event) {
|
element.bind("keyup", function (event) {
|
||||||
ngModel.$setValidity('exists', true);
|
ngModel.$setValidity('exists', false);
|
||||||
if (element.val()) {
|
if (element.val()) {
|
||||||
$http.get("/api/checkExistingUsername/" + element.val()).success(function (data) {
|
$http.get("/api/checkExistingUsername/" + element.val() + ' ').success(function (data) {
|
||||||
console.log('in existing username function');
|
console.log('in existing username function');
|
||||||
if (element.val() == scope.existingUsername) {
|
if (element.val() == scope.existingUsername) {
|
||||||
console.log('matches a username');
|
console.log("doesn't match a username");
|
||||||
ngModel.$setValidity('exists', true);
|
|
||||||
} else if (data) {
|
|
||||||
console.log("doesn't match a username")
|
|
||||||
ngModel.$setValidity('exists', false);
|
ngModel.$setValidity('exists', false);
|
||||||
|
} else if (data) {
|
||||||
|
console.log("matches a username")
|
||||||
|
ngModel.$setValidity('exists', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,16 @@ block content
|
|||||||
span.landing-icon.ion-checkmark-circled.text-primary
|
span.landing-icon.ion-checkmark-circled.text-primary
|
||||||
- if (cc)
|
- if (cc)
|
||||||
form.form-horizontal(novalidate='novalidate', name='completedWithForm')
|
form.form-horizontal(novalidate='novalidate', name='completedWithForm')
|
||||||
|
.form-group.text-center
|
||||||
|
label(for="existingUserName") If you paired with someone, enter their username here.
|
||||||
|
.col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2
|
||||||
|
input.form-control#completed-with(name="existingUser", placeholder='Otherwise just leave it blank', existing-username='', ng-model="existingUser")
|
||||||
|
.col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2(ng-show="completedWithForm.$error.exists && !completedWithForm.existingUser.$pristine")
|
||||||
|
alert(type='danger')
|
||||||
|
span.ion-close-circled
|
||||||
|
| Username not found
|
||||||
|
|
||||||
input.form-control#completed-with(name="completed-with", placeholder="If you paired with someone, enter their username here", ng-keypress='', existing-username='', ng-model="existingUsername")
|
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-bonfire-button(name='_csrf', value=_csrf, aria-hidden='true', ng-disabled='completedWithForm.$invalid') Take me to my next challenge
|
||||||
.col-sm-4.col-sm-offset-5(ng-show="completedWithForm.existingUsername.$error.unique && !completedWithForm.existingUsername.$pristine")
|
|
||||||
alert(type='danger')
|
|
||||||
span.ion-close-circled
|
|
||||||
| Username not found
|
|
||||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-bonfire-button(name='_csrf', value=_csrf, aria-hidden='true', ng-disabled='completedWithForm.$invalid') Take me to my next challenge
|
|
||||||
|
|
||||||
|
|
||||||
- if (points && points > 2)
|
- if (points && points > 2)
|
||||||
|
Reference in New Issue
Block a user