Project

General

Profile

Defect #20648 » last_connection_fix.diff

patch (Update "Last connection" value every time) - Go MAEDA, 2015-09-26 09:08

View differences:

app/controllers/application_controller.rb (working copy)
101 101
    # Check the settings cache for each request
102 102
    Setting.check_cache
103 103
    # Find the current user
104
    User.current = find_current_user
105
    logger.info("  Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})" : "anonymous")) if logger
104
    User.current = find_current_user.tap do |user|
105
      user.update_column(:last_login_on, Time.now) if user
106
      logger.info("  Current user: " + (user ? "#{user.login} (id=#{user.id})" : "anonymous")) if logger
107
    end
106 108
  end
107 109

  
108 110
  # Returns the current user or nil if no user is logged in
app/models/user.rb (working copy)
225 225
        end
226 226
      end
227 227
    end
228
    user.update_column(:last_login_on, Time.now) if user && !user.new_record? && user.active?
229 228
    user
230 229
  rescue => text
231 230
    raise text
......
234 233
  # Returns the user who matches the given autologin +key+ or nil
235 234
  def self.try_to_autologin(key)
236 235
    user = Token.find_active_user('autologin', key, Setting.autologin.to_i)
237
    if user
238
      user.update_column(:last_login_on, Time.now)
239
      user
240
    end
241 236
  end
242 237

  
243 238
  def self.name_formatter(formatter = nil)
......
554 549
        end
555 550
      end
556 551
    end
557
    
552

  
558 553
    hash.each do |role, projects|
559 554
      projects.uniq!
560 555
    end
(2-2/2)