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

verifyFunc() callback credentials arg isn't optional as expected #187

Closed
jmm opened this issue Aug 19, 2016 · 3 comments
Closed

verifyFunc() callback credentials arg isn't optional as expected #187

jmm opened this issue Aug 19, 2016 · 3 comments

Comments

@jmm
Copy link
Contributor

jmm commented Aug 19, 2016

The credentials arg to the verifyFunc() callback is documented as optional like for validateFunc(), but it's not actually. Here's a branch with that arg deleted from the relevant test code, causing failures.

The internal code for verifyFunc() doesn't default to the already decoded credentials like validateFunc() does: credentials || decoded.

Most of the work to fix this is in refactoring the test code to test both scenarios.

@nelsonic nelsonic added the bug label Aug 20, 2016
@nelsonic
Copy link
Member

@jmm well spotted! this is a Documentation issue. credentials are indeed required for verifyFunc ... do you have time to PR a the Doc Change? or is it preferable to update the tests? (thanks!)

@jmm
Copy link
Contributor Author

jmm commented Aug 21, 2016

Thanks @nelsonic! Ok, I see. My 2 cents is that I don't feel very strongly either way about credentials being required or optional for either validateFunc or verifyFunc (though it would be bc-breaking to make it required for validateFunc, of course), but I lean a bit toward it being consistent by being either optional or required in both cases.

On one hand, omitting it is a very small convenience in either case. On the other hand, I don't see a problem with allowing it to be optional on verifyFunc because you have to pass a separate valid arg anyway. So if you callback like callback(null, true), I think that's a reasonable expression that you consider the decoded credentials valid. Do you see a particular hazard to that approach that I'm overlooking?

So it's up to you. If you think it should be optional for verifyFunc then that should be fixed and the tests updated to cover it, otherwise it can just be corrected in the docs like you said.

@nelsonic
Copy link
Member

Yeah, I think my preference would be credentials || decoded so that it is optional.
Need to add another test in that case...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants