Skip to content

Commit

Permalink
Possible fix for danbooru#3460: Timeout in update_last_ip_addr.
Browse files Browse the repository at this point in the history
Set the user's statement timeout as soon as possible, before updating
anything in the database.
  • Loading branch information
evazion committed Dec 27, 2017
1 parent 659eb62 commit e34754c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/logical/session_loader.rb
Expand Up @@ -11,25 +11,22 @@ def initialize(session, cookies, request, params)
end

def load
CurrentUser.user = AnonymousUser.new

if session[:user_id]
load_session_user
elsif cookie_password_hash_valid?
load_cookie_user
else
load_session_for_api
end

if CurrentUser.user
CurrentUser.user.unban! if CurrentUser.user.ban_expired?
else
CurrentUser.user = AnonymousUser.new
end

set_statement_timeout
update_last_logged_in_at
update_last_ip_addr
set_time_zone
store_favorite_tags_in_cookies
set_statement_timeout
CurrentUser.user.unban! if CurrentUser.user.ban_expired?
end

private
Expand Down

0 comments on commit e34754c

Please sign in to comment.