Improve the validation of auth_pass#613
Conversation
If auth_pass is set, but the value is falsy like '', do_auth will not be evaluated, so the callback will never be called. Instead of check if(auth_pass), now we use if(auth_pass !== undefined) to prevent such situation.
|
How about |
|
Sorry, I was wrong, maybe adding the validation here cannot actually solve the problem (at least not enough). There's still a problem, if someone pass What do you think? |
|
At some level this is starting to feel over-protective. It may be that this is in the realm of "let the user shoot themself in the foot" -- the library simply can't protect everyone from every possible type of mistake. |
Use != instead of !== to coalesce null and undefined
|
Yeah, I understand that it is not proper to protect library user in all these kind of mistakes. But if a callback is provided, maybe it should always be called, no matter the method is successfully evaluated or not. This is just my personal opinion, if it is not correct/proper, I am sorry! |
|
Anyway, this is just a matter of taste, I have pushed the new commit, if you think this is quite enough, feel free to close this request :) |
If
auth_passis set, but the value is falsy (e.g: an empty string),do_authwill not be evaluated, so the callback ofclient.auth(pass, callback)will never be called. Instead of checkif(auth_pass), now we useif(auth_pass !== undefined)to prevent such situation.Although pass the empty string or other falsy sutff as a password make no sense, but we should leave this validation to the redis and at least let the callback of
client.auth(pass, callback)be evaluated.