Issue with custom fields in Discourse API SSO sync
vkozyrev reported an issue with the sync_sso method in the Discourse API, where custom fields are being prefixed with custom. twice, resulting in custom.custom.field_1 in the payload. This is due to the sync_sso method passing the custom. prefix to sso.custom_fields.
vkozyrev proposed a possible solution by modifying the sync_sso method to accept both DiscourseApi::SingleSignOn instances and hashes. Alternatively, they suggested defining params with a nested custom_fields hash.
However, blake pointed out that a fix for this issue was already made last month, and can be found in this commit.
This would have been a lot simpler imo, but don’t wanna break existing apps . Leave SSO instance generation up to the user.
# frozen_string_literal: true
module DiscourseApi
module API
module SSO
def sync_sso(sso)
post("/admin/users/sync_sso", sso.payload)
end
end
end
end
Maybe tomorrow I’ll do something like (but neater)
# frozen_string_literal: true
module DiscourseApi
module API
module SSO
def sync_sso(params)
if params.instance_of?(DiscourseApi::SingleSignOn)
post("/admin/users/sync_sso", sso.payload)
elsif params.instance_of?(Hash)
.... same as current
end
end
end
end
end
Thoughts? My app will ideally have a single function that generates DiscourseApi::SingleSignOn, and I’d then be able to pass it to sso_login or sync_sso