in libs/duo/__init__.py [0:0]
def remove_from_duo(self, username):
"""
Delete user by username.
:param: username: username
:return: Bool
Note: This returns a bool to show user was deleted.
"""
try:
result = None
user = username.split('@')[0]
user_data = self.get_user(user)
if len(user_data) == 0:
result = True
elif user_data is not None:
for item in user_data:
if item["username"] == user:
user_id = item["user_id"]
if self.delete_user(user_id) is True:
result = True
else:
result = False
return result
except(AttributeError, KeyError):
return "Error connecting to Duo."