Skip to content

Commit f8082ee

Browse files
committed
fix: Set thread local variables BEFORE update last login
1 parent c7a63fc commit f8082ee

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

app/controllers/concerns/authenticatable.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def authenticate_request!
3030
@current_user = User.unscoped.find(@jwt_payload[:user_id])
3131
@current_organization = @current_user.organization
3232

33+
# Set thread-local variables BEFORE update_last_login! to ensure AuditLog creation works
34+
Thread.current[:current_organization_id] = @current_organization.id
35+
Thread.current[:current_user_id] = @current_user.id
36+
Thread.current[:current_user_role] = @current_user.role
37+
3338
# Update last login time
3439
@current_user.update_last_login! if should_update_last_login?
3540
rescue Authentication::Services::JwtService::AuthenticationError => e

0 commit comments

Comments
 (0)