Skip to content

Commit 3229ef7

Browse files
committed
debug: add logging to diagnose Current attributes in production
1 parent 837d8d1 commit 3229ef7

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

app/controllers/concerns/authenticatable.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def authenticate_request!
3434
Current.user_id = @current_user.id
3535
Current.user_role = @current_user.role
3636

37+
# Debug log in production to verify Current is being set
38+
Rails.logger.info("[AUTH] Set Current.organization_id=#{Current.organization_id} for user #{@current_user.email}")
39+
3740
# Update last login time (uses update_column which skips callbacks/audit logs)
3841
@current_user.update_last_login! if should_update_last_login?
3942
rescue Authentication::Services::JwtService::AuthenticationError => e

app/models/concerns/organization_scoped.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ module OrganizationScoped
99
included do
1010
# Aplicar default_scope apenas se houver uma organização no contexto
1111
default_scope lambda {
12-
if Current.organization_id.present?
13-
where(organization_id: Current.organization_id)
12+
org_id = Current.organization_id
13+
if org_id.present?
14+
where(organization_id: org_id)
1415
else
16+
Rails.logger.warn("[SCOPE] OrganizationScoped: Current.organization_id is nil for #{name}")
1517
all
1618
end
1719
}

0 commit comments

Comments
 (0)