discourse/app/jobs/scheduled/clear_expired_impersonations.rb
Ted Johansson b24a3d81ed
DEV: Allow impersonation without session swapping (#34213)
The current impersonation feature works by signing you in as the user you are impersonating. This has the side effect of invalidating your own session and forcing you to log out and in again.

In this experimental implementation you keep your existing session, but DefaultCurrentUserProvider returns the user being impersonated, allowing you to see the site from their perspective.
2025-08-21 14:18:15 +08:00

14 lines
316 B
Ruby

# frozen_string_literal: true
module Jobs
class ClearExpiredImpersonations < ::Jobs::Scheduled
every 30.minutes
def execute(args)
UserAuthToken.where("impersonation_expires_at < NOW()").update_all(
impersonated_user_id: nil,
impersonation_expires_at: nil,
)
end
end
end