bans: fix exception when user with expired ban logs in.
`ban.destroy` fails because users have many `bans`, not a single `ban`. Destroying the expired ban isn't necessary anyway.
This commit is contained in:
@@ -20,7 +20,7 @@ class SessionLoader
|
||||
end
|
||||
|
||||
if CurrentUser.user
|
||||
CurrentUser.user.unban! if ban_expired?
|
||||
CurrentUser.user.unban! if CurrentUser.user.ban_expired?
|
||||
else
|
||||
CurrentUser.user = AnonymousUser.new
|
||||
end
|
||||
@@ -86,10 +86,6 @@ private
|
||||
session[:user_id] = CurrentUser.user.id
|
||||
end
|
||||
|
||||
def ban_expired?
|
||||
CurrentUser.user.is_banned? && CurrentUser.user.recent_ban && CurrentUser.user.recent_ban.expired?
|
||||
end
|
||||
|
||||
def cookie_password_hash_valid?
|
||||
cookies[:password_hash] && cookies.signed[:user_name] && User.authenticate_cookie_hash(cookies.signed[:user_name], cookies[:password_hash])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user