0001-Update-User-last_login_on-only-once-per-minute-and-u.patch

Holger Just, 2018-06-05 10:18

Download (1.45 KB)

View differences:

app/models/user.rb
239 239
        end
240 240
      end
241 241
    end
242
    user.update_column(:last_login_on, Time.now) if user && !user.new_record? && user.active?
242
    user.update_last_login_on! if user && !user.new_record? && user.active?
243 243
    user
244 244
  rescue => text
245 245
    raise text
......
249 249
  def self.try_to_autologin(key)
250 250
    user = Token.find_active_user('autologin', key, Setting.autologin.to_i)
251 251
    if user
252
      user.update_column(:last_login_on, Time.now)
252
      user.update_last_login_on!
253 253
      user
254 254
    end
255 255
  end
......
315 315
    update_attribute(:status, STATUS_LOCKED)
316 316
  end
317 317

  
318
  def update_last_login_on!
319
    return if last_login_on.present? && last_login_on >= 1.minute.ago
320

  
321
    update_column(:last_login_on, Time.now)
322
  end
323

  
318 324
  # Returns true if +clear_password+ is the correct user's password, otherwise false
319 325
  def check_password?(clear_password)
320 326
    if auth_source_id.present?
321
-