示例#1
0
文件: views.py 项目: vinithra/hue
def get_current_users():
  """Return dictionary of User objects and
  a dictionary of the user's IP address and last access time"""
  current_users = { }
  for session in Session.objects.all():
    uid = session.get_decoded().get(django.contrib.auth.SESSION_KEY)
    if uid is not None:
      try:
        userobj = User.objects.get(pk=uid)
      except User.DoesNotExist:
        LOG.debug("User with id=%d does not exist" % uid)
      current_users[userobj] = last_access_map.get(userobj.username, { })

  return current_users
示例#2
0
def get_current_users():
  """Return dictionary of User objects and a dictionary of the user's IP address and last access time"""
  current_users = { }
  for session in Session.objects.all():
    try:
      uid = session.get_decoded().get(django.contrib.auth.SESSION_KEY)
    except SuspiciousOperation:
      # If secret_key changed, this resolution won't work.
      uid = None

    if uid is not None:
      try:
        userobj = User.objects.get(pk=uid)
        current_users[userobj] = last_access_map.get(userobj.username, { })
      except User.DoesNotExist:
        LOG.debug("User with id=%d does not exist" % uid)

  return current_users