Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
FIX: Avoid using GlobalSetting for crowd_custom_html (#20)
Browse files Browse the repository at this point in the history
The discourse.conf file doesn't handle strings with single quotes in them. Therefore we can't use the GlobalSetting interface, and need to reach directly for the ENV.

Not ideal, and can possibly be improved in future updates of 'launcher', and the discourse.conf file. For now, this commit will solve the issue for this plugin.
  • Loading branch information
davidtaylorhq committed Nov 30, 2021
1 parent ddfbe02 commit 7e1a690
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugin.rb
Expand Up @@ -127,7 +127,12 @@ def set_groups(user, auth)
end
end

class CrowdAuthenticator < ::Auth::OAuth2Authenticator
class ::Auth::CrowdAuthenticator < ::Auth::OAuth2Authenticator
# The discourse.conf file doesn't handle strings with single quotes in them.
# Therefore we can't use the GlobalSetting interface, and need to reach directly for the ENV.
# Not ideal, and can possibly be improved in future updates of 'launcher', and the discourse.conf file.
CROWD_HTML = ENV["DISCOURSE_CROWD_CUSTOM_HTML"]

def register_middleware(omniauth)
return unless GlobalSetting.try(:crowd_server_url).present?

Expand Down Expand Up @@ -155,8 +160,8 @@ def get_credentials
html "\n<input type='hidden' name='authenticity_token' value='#{token}'/>" if token
button 'Login'

if GlobalSetting.respond_to?(:crowd_custom_html)
html GlobalSetting.crowd_custom_html
if ::Auth::CrowdAuthenticator::CROWD_HTML
html ::Auth::CrowdAuthenticator::CROWD_HTML
end
end.to_response
end
Expand Down Expand Up @@ -195,4 +200,4 @@ def enabled?
end

auth_provider title: GlobalSetting.try(:crowd_title),
authenticator: CrowdAuthenticator.new('crowd')
authenticator: ::Auth::CrowdAuthenticator.new('crowd')

0 comments on commit 7e1a690

Please sign in to comment.