Adding in existing username checking, NOT WORKING AT THE MOMENT
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user