def verify_secret_key(request):
 if request.user.username:
  return True
 else:
  key = request.GET['secret']
  (user_id, secret) = key.split('.', 1)
  try:
   profile = User.objects.get(pk=user_id)
  except:
   return False
  if (key == get_secret_key(request, profile)):
   request.user = profile.user
   return True
 return False

def verify_secret_key ( request ) : if request . user . username : return True else : key = request . GET [ 'secret' ] ( user_id , secret ) = key . split ( '.' , 1 ) try : profile = User . objects . get ( pk = user_id ) except : return False if ( key == get_secret_key ( request , profile ) ) : request . user = profile . user return True return False
verifies secret key for a request .