foodsoft/plugins/discourse/app/controllers/discourse_sso_controller.rb
Philipp Rothmann fb2b4d8a8a chore: rubocop
chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
2023-06-09 17:35:05 +02:00

23 lines
884 B
Ruby

class DiscourseSsoController < DiscourseController
before_action -> { require_config_enabled :discourse_sso }
def sso
raise I18n.t('discourse.sso.invalid_signature') unless valid_signature?
payload = parse_payload
nonce = payload[:nonce]
return_sso_url = payload[:return_sso_url] || "#{discourse_url}/session/sso_login"
raise I18n.t('discourse.sso.nonce_missing') if nonce.blank?
redirect_to_with_payload return_sso_url,
nonce: nonce,
email: current_user.email,
require_activation: true,
external_id: "#{FoodsoftConfig.scope}/#{current_user.id}",
username: current_user.nick,
name: current_user.name
rescue StandardError => e
redirect_to root_url, alert: e.to_s
end
end