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: do not attempt to fetch user JSON if URL is not set #94

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def after_authenticate(auth, existing_account: nil)
#{auth["extra"].to_hash.to_yaml}
LOG

if SiteSetting.oauth2_fetch_user_details?
if SiteSetting.oauth2_fetch_user_details? && SiteSetting.oauth2_user_json_url.present?
if fetched_user_details = fetch_user_details(auth["credentials"]["token"], auth["uid"])
auth["uid"] = fetched_user_details[:user_id] if fetched_user_details[:user_id]
auth["info"]["nickname"] = fetched_user_details[:username] if fetched_user_details[
Expand Down
2 changes: 2 additions & 0 deletions spec/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

describe OAuth2BasicAuthenticator do
describe "after_authenticate" do
before { SiteSetting.oauth2_user_json_url = "https://provider.com/user" }

let(:user) { Fabricate(:user) }
let(:authenticator) { OAuth2BasicAuthenticator.new }

Expand Down
Loading