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

FIX: Appropriately assign values when fetching user details #100

Merged
merged 3 commits into from
Mar 21, 2024

Conversation

nattsw
Copy link
Contributor

@nattsw nattsw commented Mar 21, 2024

Currently, in a user json with false values, due to a || operator, the value incorrectly evaluates to the right hand side. This was causing an issue.

e.g.

deref = fragment[first_seg] || fragment[first_seg.to_sym]

This PR fixes that and appropriately assigns false to the specified path for user details.

@@ -113,7 +113,8 @@ def json_walk(result, user_json, prop, custom_path: nil)
path = path.gsub(".[].", ".").gsub(".[", "[")
segments = parse_segments(path)
val = walk_path(user_json, segments)
result[prop] = val if val.present?
# [] should be nil, false should be false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a test for the []->nil
it "can walk json and handle an empty array" do

lib/oauth2_basic_authenticator.rb Outdated Show resolved Hide resolved
lib/oauth2_basic_authenticator.rb Outdated Show resolved Hide resolved
nattsw and others added 2 commits March 21, 2024 17:34
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
@nattsw nattsw merged commit f11229a into main Mar 21, 2024
3 checks passed
@nattsw nattsw deleted the assign-false-correctly branch March 21, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants