bnoguchi/everyauth — Issue #96: registerUser continues without validateRegistration
Author: PatrickHeneise
Created: 2011-10-11 08:45:53+00:00
State: open

nano.user() returns a user (header 200) or an error (404). I'd like to use these errors in the registration validation, but it doesn't work:

```javascript
.validateRegistration(function (newUserAttrs, errors) {
nano.user(newUserAttrs.email, function(error, document, headers) {
if(error) {
if(error.error != 'not_found') // push any error except 404
errors.push(error.error);
}
if(headers['status-code'] === 200) {
console.log("Error: User Exists");
errors.push("User Exists");
}
});
console.log("Error: " + errors);
return errors;
})
```

```
starting step - validateRegistration
Error:
...finished step
starting step - maybeBreakToRegistrationFailSteps
...finished step
starting step - registerUser
Error: User Exists
...finished step
starting step - extractUserOrHandleErrors
```

The error is pushed after the call for registerUser and therefore the registration process is complete before an error can displayed. What would be the best solution here?