def reset_password()

in libs/google/admin.py [0:0]


  def reset_password(self, user_key):
    """
    Resets a user's password.
    :param user_key: userKey
    :return: bool
    Note: The password field is always returned empty.
    """
    result = True
    passwd = HelperFunctions().hash_passwd()
    try:
      r = json.loads(self.call_google_api(service=self.service,
                                          api_resource="users",
                                          api_method="update",
                                          response_field=None,
                                          userKey=user_key,
                                          body={"password": passwd,
                                                "hashFunction": "SHA-1"}))
      if "password" in r:
        if r["password"] == "":
          result = True
    except(ValueError, KeyError, TypeError):
      result = False
    return result