Slightly More Efficient
A slightly more efficient implementation of the above change to form_spam_protection.
This commit is contained in:
parent
72b4f97382
commit
e7d080db25
1 changed files with 4 additions and 2 deletions
|
@ -9,8 +9,10 @@ module ActionView
|
|||
session[:form_keys] ||= {}
|
||||
form_key = Digest::SHA1.hexdigest(self.object_id.to_s + rand.to_s)
|
||||
session[:form_keys][form_key] = [Time.now, 0]
|
||||
first = session[:form_keys].values.sort { |a,b| a[0] <=> b[0] } [0]
|
||||
session[:form_keys].delete(session[:form_keys].index(first)) if session[:form_keys].length > 30
|
||||
if session[:form_keys].length > 30
|
||||
first = session[:form_keys].values.sort { |a,b| a[0] <=> b[0] } [0]
|
||||
session[:form_keys].delete(session[:form_keys].index(first))
|
||||
end
|
||||
out << domEnkode(form_key)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue