Adding in existing username checking, NOT WORKING AT THE MOMENT

This commit is contained in:
Nathan Leniz
2015-01-24 04:14:41 -05:00
parent a3cf6c3ee2
commit 022b8daddc
4 changed files with 57 additions and 3 deletions

View File

@@ -94,6 +94,13 @@ profileValidation.controller('profileValidationController', ['$scope', '$http',
}
]);
profileValidation.controller('pairedWithController', ['$scope',
function($scope) {
}
]);
profileValidation.controller('emailSignUpController', ['$scope',
function($scope) {
@@ -138,6 +145,30 @@ profileValidation.directive('uniqueUsername', function($http) {
}
}
});
// TODO: FIX THIS
profileValidation.directive('existingUsername', function($http) {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ngModel) {
element.bind("keyup", function (event) {
ngModel.$setValidity('exists', true);
if (element.val()) {
$http.get("/api/checkExistingUsername/" + element.val()).success(function (data) {
console.log('in existing username function');
if (element.val() == scope.existingUsername) {
console.log('matches a username');
ngModel.$setValidity('exists', true);
} else if (data) {
console.log("doesn't match a username")
ngModel.$setValidity('exists', false);
}
});
}
});
}
}
});
profileValidation.directive('uniqueEmail', function($http) {
return {