Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue passing errors to validateFunc #10

Merged
merged 1 commit into from Aug 4, 2014
Merged

Conversation

@johnbrett
Copy link
Contributor

johnbrett commented Jul 31, 2014

I noticed if you pass a non-null value that is not an instance of Error as err to validateFunc it will return a 200 status code, even with isValid set to false e.g.

validateFunc: function(username, password, callback) {
  return callback({error: 'test error'}, false, null)
}

This PR just contains a unit case to highlight this, what should the expected behaviour be here?

I noticed if you pass a non-null value, that is not an instance of
Error as err to validateFunc it will return a 200 status code, even
with isValid set to false e.g.
````
validateFunc: function(username, password, callback) {
return callback({error: 'test error'}, false, null)
}
````
This PR just contains a unit case to highlight this, what should the
expected behaviour be here?
hueniverse added a commit that referenced this pull request Aug 4, 2014
issue passing errors to validateFunc
@hueniverse hueniverse merged commit 3c31f27 into hapijs:master Aug 4, 2014
1 check failed
1 check failed
continuous-integration/travis-ci The Travis CI build failed
Details
hueniverse added a commit that referenced this pull request Aug 4, 2014
@hueniverse hueniverse added the non-issue label Aug 4, 2014
@hueniverse hueniverse added this to the 1.1.1 milestone Aug 4, 2014
@hueniverse hueniverse self-assigned this Aug 4, 2014
@hueniverse

This comment has been minimized.

Copy link
Member

hueniverse commented Aug 4, 2014

This is actually working as expected. Note that the handler is never called (the request is actually marked as unauthenticated), and that the 200 response payload is the content of the error value provided. For example, this allows you to do a redirect when the password is incorrect.

@johnbrett

This comment has been minimized.

Copy link
Contributor Author

johnbrett commented Aug 5, 2014

That makes more sense, thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.