]> cat aescling's git repositories - mastodon.git/commitdiff
Avoid return within block (#17590)
authorzunda <zundan@gmail.com>
Fri, 18 Feb 2022 19:21:21 +0000 (19:21 +0000)
committerGitHub <noreply@github.com>
Fri, 18 Feb 2022 19:21:21 +0000 (20:21 +0100)
This prevents the error: LocalJumpError (unexpected return)

config/initializers/rack_attack.rb

index 80c005f81983994cbf0fad7beca7a122b4d741aa..a1fea7712de7cb9ccc29d70ae3117eacfc5925f0 100644 (file)
@@ -82,9 +82,13 @@ class Rack::Attack
   end
 
   throttle('throttle_sign_up_attempts/ip', limit: 25, period: 5.minutes) do |req|
-    return unless req.post? && req.path == '/auth'
-    return req.remote_ip.mask(64) if req.remote_ip.ipv6?
-    req.remote_ip
+    if req.post? && req.path == '/auth'
+      if req.remote_ip.ipv6?
+        req.remote_ip.mask(64)
+      else
+        req.remote_ip
+      end
+    end
   end
 
   throttle('throttle_password_resets/ip', limit: 25, period: 5.minutes) do |req|