def get_user_from_cookie_or_legacy_auth(request):
  if 'HTTP_AUTHORIZATION' in request.META:
    username, password = auth_basic_get_credentials(request.META['HTTP_AUTHORIZATION'])
    return lookup_user_by_login(username, password)

  nick = request.COOKIES.get(settings.USER_COOKIE, None)
  token = request.COOKIES.get(settings.PASSWORD_COOKIE, None)
  if nick:
    # try to authenticate the dude via cookie
    user = authenticate_user_cookie(nick, token)
    return user

  if (settings.API_ALLOW_LEGACY_AUTH
      and 'personal_key' in request.REQUEST
      and 'user' in request.REQUEST):
    user = legacy.authenticate_user_personal_key(
        request.REQUEST['user'], request.REQUEST['personal_key'])
    if user:
      user.legacy = True
    return user

  return None
attempt to get a logged in user based on the request
dataset/ETHPy150Open CollabQ/CollabQ/common/user.py/get_user_from_cookie_or_legacy_auth