Skip to content

Commit

Permalink
fix guest lookup to be unscoped (#2395)
Browse files Browse the repository at this point in the history
* fix guest lookup to be unscoped
  • Loading branch information
orangewolf authored Dec 18, 2024
1 parent cf5a4fc commit 012cb43
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ApplicationController < ActionController::Base
with_themed_layout '1_column'

include HykuHelper
include DeviseGuestControllersHelpersDecorator

helper_method :current_account, :admin_host?, :home_page_theme, :show_page_theme, :search_results_theme
before_action :authenticate_if_needed
Expand Down
27 changes: 27 additions & 0 deletions app/controllers/devise_guest_controllers_helpers_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

# OVERRIDE devise-invitable 2.0.9 to unscope user look up
module DeviseGuestControllersHelpersDecorator
def guest_user
return @guest_user if @guest_user

if session[:guest_user_id]
begin
@guest_user = User.unscoped.find_by(User.authentication_keys.first => session[:guest_user_id])
rescue
@guest_user = nil
end
@guest_user = nil if @guest_user.respond_to?(:guest) && !@guest_user.guest
end

@guest_user ||= begin
u = create_guest_user(session[:guest_user_id])
session[:guest_user_id] = u.send(User.authentication_keys.first)
u
end

@guest_user
end
end

DeviseGuests::Controllers::Helpers.prepend(DeviseGuestControllersHelpersDecorator)

0 comments on commit 012cb43

Please sign in to comment.