Avoid redundant OAuth queries when not signed in
If you aren't signed in, you don't have an auth token. When you don't have an auth token, React was sending the headers "Authorization: Bearer null" This caused 5 Doorkeeper token lookups using WHERE "oauth_access_tokens"."token" = 'null' on the Explore page (the root of the app when not signed in).
This commit is contained in:
@@ -7,7 +7,7 @@ default: &default
|
||||
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
|
||||
|
||||
development:
|
||||
master:
|
||||
primary:
|
||||
<<: *default
|
||||
url: <%= ENV['DB_MASTER_URL'] %>
|
||||
slave1:
|
||||
@@ -39,7 +39,7 @@ test:
|
||||
# port: <%= ENV['DB_PORT'] || 5432 %>
|
||||
# prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>
|
||||
production:
|
||||
master:
|
||||
primary:
|
||||
<<: *default
|
||||
url: <%= ENV['DB_MASTER_URL'] %>
|
||||
slave1:
|
||||
|
||||
@@ -76,6 +76,14 @@ module Devise
|
||||
end
|
||||
|
||||
Devise.setup do |config|
|
||||
|
||||
config.warden_hook_save_wrapper = Proc.new do |hook|
|
||||
# ensure the writable connection is used to avoid read-only write errors
|
||||
ApplicationRecord.connected_to(role: :writing) do
|
||||
hook.call
|
||||
end
|
||||
end
|
||||
|
||||
config.warden do |manager|
|
||||
manager.default_strategies(scope: :user).unshift :ldap_authenticatable if Devise.ldap_authentication
|
||||
manager.default_strategies(scope: :user).unshift :pam_authenticatable if Devise.pam_authentication
|
||||
|
||||
@@ -7,6 +7,13 @@ Devise.setup do |config|
|
||||
options = {}
|
||||
options[:redirect_at_sign_in] = ENV['OAUTH_REDIRECT_AT_SIGN_IN'] == 'true'
|
||||
|
||||
config.warden_hook_save_wrapper = Proc.new do |hook|
|
||||
# ensure the writable connection is used to avoid read-only write errors
|
||||
ApplicationRecord.connected_to(role: :writing) do
|
||||
hook.call
|
||||
end
|
||||
end
|
||||
|
||||
# CAS strategy
|
||||
if ENV['CAS_ENABLED'] == 'true'
|
||||
cas_options = options
|
||||
|
||||
Reference in New Issue
Block a user