إدخال غير صالح لتحديث عنوان IP

Lucky you. Because of the higher cost we needed to switch back to SKU V1 as soon as the V2 preview has ended.

Anyway, it seems that this issue/case has already been addressed upstream by a merged PR and should be included since rack 2.0. But according to this issue it is still missing in the current releases.

Temporarily I apply a patch during CI/CD to handle this issue. It’s not that great but it will do the job until we see the fix in an upcoming rack-/discourse-release.

If anyone is interested, that’s the part you need to change to get rid of the extra port in lib/auth/default_current_user_provider.rb:

if current_user && should_update_last_seen?
  u = current_user
  ip_port_split = request.ip.split(':')
  ip_only = ip_port_split.first
  Scheduler::Defer.later "Updating Last Seen" do
    u.update_last_seen!
    u.update_ip_address!(ip_only)
  end
end

I don’t know if it is a good idea to replace any occurrence of request.ip with this quickfix anywhere else in that file or others (email_controller.rb, 006-mini_profiler.rb, request_tracker.rb) but it works for us.
As said, applying it as a patch during your build-/CI-processes keeps the code-base clean and updatable.

Any “prettier” solution is welcome.

3 إعجابات