fix user.exists returns an object with property exists

This commit is contained in:
Berkeley Martinez
2015-06-10 17:21:57 -07:00
parent f3b1b5ca0d
commit 147f1d1d37

View File

@ -427,10 +427,10 @@ profileValidation.directive('uniqueUsername', ['$http', function($http) {
var config = { params: { username: username } }; var config = { params: { username: username } };
$http $http
.get('/api/users/exists', config) .get('/api/users/exists', config)
.success(function (exists) { .success(function (result) {
if (username === scope.storedUsername) { if (username === scope.storedUsername) {
ngModel.$setValidity('unique', true); ngModel.$setValidity('unique', true);
} else if (exists) { } else if (result.exists) {
ngModel.$setValidity('unique', false); ngModel.$setValidity('unique', false);
} }
}); });
@ -458,8 +458,8 @@ profileValidation.directive('existingUsername',
var config = { params: { username: username } }; var config = { params: { username: username } };
$http $http
.get('/api/users/exists', config) .get('/api/users/exists', config)
.success(function(exists) { .success(function(result) {
ngModel.$setValidity('exists', exists); ngModel.$setValidity('exists', result.exists);
}); });
} }
}); });
@ -479,10 +479,10 @@ profileValidation.directive('uniqueEmail', ['$http', function($http) {
var config = { params: { email: email } }; var config = { params: { email: email } };
$http $http
.get('/api/users/exists', config) .get('/api/users/exists', config)
.success(function (exists) { .success(function(result) {
if (email === scope.storedEmail) { if (email === scope.storedEmail) {
ngModel.$setValidity('unique', true); ngModel.$setValidity('unique', true);
} else if (exists.exists) { } else if (result.exists) {
ngModel.$setValidity('unique', false); ngModel.$setValidity('unique', false);
} }
}); });