Return friendly error message when creating user with invalid password#1087
Merged
rnewson merged 2 commits intoapache:masterfrom Jan 6, 2018
Merged
Conversation
rnewson
approved these changes
Jan 4, 2018
Member
rnewson
left a comment
There was a problem hiding this comment.
It's a good patch, well done. I think it would be good to do the same for invalid "salt" fields following the same method. I've approved this as it is but can re-review if you decide to add better errors for bad "salt" values.
| simple(Password, Salt) when is_binary(Password), is_binary(Salt) -> | ||
| ?l2b(couch_util:to_hex(crypto:hash(sha, <<Password/binary, Salt/binary>>))). | ||
| ?l2b(couch_util:to_hex(crypto:hash(sha, <<Password/binary, Salt/binary>>))); | ||
| simple(Password, Salt) when is_binary(Salt) -> |
Member
There was a problem hiding this comment.
How about another clause for when the salt field is not a string?
Contributor
Author
There was a problem hiding this comment.
Good suggestion. Added
| {ok, Result} = pbkdf2(Password, Salt, Iterations, ?SHA1_OUTPUT_LENGTH), | ||
| Result. | ||
| Result; | ||
| pbkdf2(Password, Salt, Iterations) when is_binary(Salt), |
Contributor
Author
d7218cc to
f913ff7
Compare
- Return friendly error message instead of returning unknown_error
and function_clause when creating a use with non-string password.
issue 1051
issue 1051
Contributor
Author
|
Thanks again, Bob. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Before this PR, couch returns unknown_error/function_clause when creating a user with non-string password.
This PR is aimed to return one friendly error message when creating user with invalid password.
Testing recommendations
Related Issues or Pull Requests
issue #1051
Checklist