From c1116a65e942cd154f1dfc5db84b52d5c3717832 Mon Sep 17 00:00:00 2001 From: Frances McMullin Date: Fri, 23 Apr 2021 19:31:28 +0100 Subject: [PATCH 1/5] Avoid secondary activate admin session cookie --- app/app.rb | 3 --- app/views/login.erb | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/app.rb b/app/app.rb index 5b37040..6e6257e 100644 --- a/app/app.rb +++ b/app/app.rb @@ -8,11 +8,8 @@ class App < Padrino::Application helpers Activate::ParamHelpers helpers Activate::NavigationHelpers - enable :sessions - if ENV['SSL'] use Rack::SslEnforcer - use Rack::Session::Cookie, :key => '_rack_session', :path => '/', :expire_after => 30*24*60*60, :secret => ENV['SESSION_SECRET'] else set :sessions, :expire_after => 1.year end diff --git a/app/views/login.erb b/app/views/login.erb index ccf69bb..6848da4 100644 --- a/app/views/login.erb +++ b/app/views/login.erb @@ -1,6 +1,10 @@ <% form_tag url(:login), :class => 'form-horizontal' do %> + <% if params[:redir] %> + <%= hidden_field_tag :redir, :value => params[:redir] %> + <% end %> +
From 21736875d6ac85a6e1ce695aafa7059ec45beb41 Mon Sep 17 00:00:00 2001 From: Frances McMullin Date: Sat, 24 Apr 2021 03:21:33 +0100 Subject: [PATCH 2/5] Remove session set to avoid clobbering redis sessions --- app/app.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/app.rb b/app/app.rb index 6e6257e..276e7c0 100644 --- a/app/app.rb +++ b/app/app.rb @@ -10,8 +10,6 @@ class App < Padrino::Application if ENV['SSL'] use Rack::SslEnforcer - else - set :sessions, :expire_after => 1.year end def initialize From ef2cf36dfd8bbf450fcd7f32fb3814fcb08ca946 Mon Sep 17 00:00:00 2001 From: Frances McMullin Date: Fri, 23 Apr 2021 19:31:45 +0100 Subject: [PATCH 3/5] Provide login redirect in prod as well as dev --- app/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.rb b/app/app.rb index 276e7c0..7136a50 100644 --- a/app/app.rb +++ b/app/app.rb @@ -391,7 +391,7 @@ def initialize if account = Account.authenticate(params[:email], params[:password]) session[:account_id] = account.id flash[:notice] = "Logged in successfully." - redirect url(:home) + redirect params[:redir] or url(:home) elsif Padrino.env == :development && params[:bypass] account = Account.first session[:account_id] = account.id From c742270dff5bb152b1c49d1676ca616186a1d6db Mon Sep 17 00:00:00 2001 From: Frances McMullin Date: Wed, 20 Apr 2022 13:09:10 +0100 Subject: [PATCH 4/5] Remove dependency on active-admin-any_of --- app/app.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/app.rb b/app/app.rb index 7136a50..85bc849 100644 --- a/app/app.rb +++ b/app/app.rb @@ -110,7 +110,14 @@ def initialize end } if active_record? - @resources = @resources.where.any_of(*query) if !query.empty? + if !query.empty? + head, *tail = query + sub_resources = @resources.where(head) # add at least one concrete condition + tail.each do |cond| + sub_resources = sub_resources.or(@resources.where(cond)) + end + @resources = sub_resources + end elsif mongoid? @resources = @resources.or(query) end @@ -283,7 +290,14 @@ def initialize end when 'any' if active_record? - @resources = @resources.where.any_of(*query) if !query.empty? + if !query.empty? + head, *tail = query + sub_resources = @resources.where(head) # add at least one concrete condition + tail.each do |cond| + sub_resources = sub_resources.or(@resources.where(cond)) + end + @resources = sub_resources + end elsif mongoid? @resources = @resources.or(query) end From cacc0760becd03dfe74a4d4cf37031b65f1f0a15 Mon Sep 17 00:00:00 2001 From: Frances McMullin Date: Wed, 19 Nov 2025 13:14:33 +0000 Subject: [PATCH 5/5] Update for AR 7.2.3 - connection pools hurray --- app/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.rb b/app/app.rb index 3d228f7..38cf76d 100644 --- a/app/app.rb +++ b/app/app.rb @@ -13,7 +13,7 @@ class App < Padrino::Application end def initialize - unless ActiveRecord::Base.connection.active? + unless ActiveRecord::Base.connection.active? || ActiveRecord::Base.connection_pool.active_connection? if ENV['DATABASE_URL'] and ENV['DATABASE_SCHEMA'] ActiveRecord::Base.establish_connection(ENV['DATABASE_URL']) ActiveRecord::Base.connection.schema_search_path = ENV['DATABASE_SCHEMA']