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
This commit is contained in:
Philipp Rothmann 2023-05-12 13:01:12 +02:00 committed by Philipp Rothmann
parent f6fb804bbe
commit fb2b4d8a8a
331 changed files with 4263 additions and 4507 deletions

View file

@ -11,7 +11,7 @@ class DiscourseController < ApplicationController
def redirect_to_with_payload(url, payload)
base64_payload = Base64.strict_encode64 payload.to_query
sso = CGI::escape base64_payload
sso = CGI.escape base64_payload
sig = get_hmac_hex_string base64_payload
redirect_to "#{url}#{url.include?('?') ? '&' : '?'}sso=#{sso}&sig=#{sig}"
end
@ -21,7 +21,7 @@ class DiscourseController < ApplicationController
payload.symbolize_keys!
end
def get_hmac_hex_string payload
def get_hmac_hex_string(payload)
discourse_sso_secret = FoodsoftConfig[:discourse_sso_secret]
OpenSSL::HMAC.hexdigest 'sha256', discourse_sso_secret, payload
end

View file

@ -5,7 +5,7 @@ class DiscourseLoginController < DiscourseController
def initiate
discourse_url = FoodsoftConfig[:discourse_url]
nonce = SecureRandom.hex()
nonce = SecureRandom.hex
return_sso_url = url_for(action: :callback, only_path: false)
session[:discourse_sso_nonce] = nonce
@ -36,7 +36,7 @@ class DiscourseLoginController < DiscourseController
user.save!
login_and_redirect_to_return_to user, notice: I18n.t('discourse.callback.logged_in')
rescue => error
redirect_to login_url, alert: error.to_s
rescue StandardError => e
redirect_to login_url, alert: e.to_s
end
end

View file

@ -17,7 +17,7 @@ class DiscourseSsoController < DiscourseController
external_id: "#{FoodsoftConfig.scope}/#{current_user.id}",
username: current_user.nick,
name: current_user.name
rescue => error
redirect_to root_url, alert: error.to_s
rescue StandardError => e
redirect_to root_url, alert: e.to_s
end
end