diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6ab43ce..2df04b5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,17 +19,13 @@ private def current_account @current_account ||= current_user&.account - end - - def guest_account - @guest_account ||= current_account - @guest_account ||= Account.guests.find_by(id: session[:guest_account_id]) + @current_account ||= Account.guests.find_by(id: session[:guest_account_id]) end def pundit_user @pundit_user ||= ApplicationPolicy::Context.new( - account: current_account, - guest_account: guest_account, + account: current_account&.guest? ? nil : current_account, + guest_account: current_account, ) end diff --git a/app/controllers/membership_apps_controller.rb b/app/controllers/membership_apps_controller.rb index 8b1f367..a45777c 100644 --- a/app/controllers/membership_apps_controller.rb +++ b/app/controllers/membership_apps_controller.rb @@ -19,7 +19,7 @@ class MembershipAppsController < ApplicationController def create @membership_app = MembershipApp.new permitted_attributes MembershipApp - @membership_app.account = guest_account || Account.new + @membership_app.account = current_account || Account.new authorize @membership_app