]> cat aescling's git repositories - mastodon.git/commitdiff
Fix error when trying to register (#17600)
authorClaire <claire.github-309c@sitedethib.com>
Mon, 21 Feb 2022 13:55:38 +0000 (14:55 +0100)
committerGitHub <noreply@github.com>
Mon, 21 Feb 2022 13:55:38 +0000 (14:55 +0100)
config/initializers/rack_attack.rb

index a1fea7712de7cb9ccc29d70ae3117eacfc5925f0..c3733e377f71b44da4251d5220788b2b960222f7 100644 (file)
@@ -83,11 +83,10 @@ class Rack::Attack
 
   throttle('throttle_sign_up_attempts/ip', limit: 25, period: 5.minutes) do |req|
     if req.post? && req.path == '/auth'
-      if req.remote_ip.ipv6?
-        req.remote_ip.mask(64)
-      else
-        req.remote_ip
-      end
+      addr = req.remote_ip
+      addr = IPAddr.new(addr) if addr.is_a?(String)
+      addr = addr.mask(64) if addr.ipv6?
+      addr.to_s
     end
   end