def XsrfTokenValidate(token, action, user=None, timestamp=None, time_=time):
  """Validate an XSRF token."""
  if not token:
    return False
  if not user:
    user = users.get_current_user().email()
  if not timestamp:
    try:
      _, timestr = base64.b64decode(token).split(XSRF_DELIMITER, 1)
      timestamp = float(timestr)
    except (ValueError, TypeError):
      return False

  if timestamp + XSRF_VALID_TIME < time_.time():
    return False
  if token != XsrfTokenGenerate(action, user, timestamp):
    return False
  return True
dataset/ETHPy150Open google/simian/src/simian/mac/admin/xsrf.py/XsrfTokenValidate/original