Repository: google/timesketch

Issue:
Delete user / groups
During Documentation creation I realised there is at the moment no method to delete users / groups

Lacking insights, I was not sure if deleting a user might crash other concepts like tags, comments etc. 

At least having an issue for people to see, there is at the moment no such think like deleting users.

Workaround if you want to block access for a user is setting his password to a value that he does not know.


Discussion:
In the User model we have a boolean attribute called "active", and the indented use is to deactivate a user. We should make it possible to inactivate a user via tsctl.
I will give that one a try to implement.
- [ ] introduce disable_user to tsctl
- [ ] implement disable_user
- [ ] introduce def set_enable_disable(self, plaintext): to models/user.py
- [ ] add information to user_guide how to disable user and why not deleting user

If we introduce disable user, an enable user would be good as well... so I will cover that
This is still not possible in tsctl. Do you want to add it @jaegeral ??
Bumping this feature request. @jaegeral le me know if you still want to add this.
I think it would still be a useful feature, yes
freeing this Feature request for now as I had no time to work on it for a while if someone wants to pick it up.
Hello! We are a group of undergraduate students from Carnegie Mellon University working on a software engineering class project. We have been tasked with contributing to an open-source project, and we are very interested in this one! We want to take a look at this issue and implement this feature. Please let us know if there is anything else you can let us know about this feature. Thanks!
[https://github.com/dyou3968](url)
[https://github.com/joshjzhou](url)
[https://github.com/tyjlowe](url)
[https://github.com/LeoAndTheTree](url)
Hey @LeoAndTheTree I think there should be plenty of info already in this Issue, let me know if you have any further question and thank you for picking it up.

Resolving patch:
diff --git a/timesketch/tsctl.py b/timesketch/tsctl.py
--- a/timesketch/tsctl.py
+++ b/timesketch/tsctl.py
@@ -154,6 +154,47 @@ def run(self, username, remove):
         else:
             sys.stdout.write('User {0:s} is now an admin.\n'.format(username))
 
+class DisableUser(Command):
+    """Disable User"""
+    option_list = (
+        Option('--username', '-u', dest='username', required=True),
+    )
+
+    # pylint: disable=arguments-differ, method-hidden
+    def run(self, username):
+        """Sets the active bit of a user to false."""
+        user = User.query.filter_by(username=username).first()
+
+        if not user:
+            sys.stdout.write('User [{0:s}] does not exist.\n'.format(
+                username))
+            return
+        user.active = False
+        db_session.add(user)
+        db_session.commit()
+
+        sys.stdout.write('User {0:s} is deactivated.\n'.format(username))
+
+class EnableUser(Command):
+    """Enable User"""
+    option_list = (
+        Option('--username', '-u', dest='username', required=True),
+    )
+
+    # pylint: disable=arguments-differ, method-hidden
+    def run(self, username):
+        """Sets the active bit of a user to true."""
+        user = User.query.filter_by(username=username).first()
+
+        if not user:
+            sys.stdout.write('User [{0:s}] does not exist.\n'.format(
+                username))
+            return
+        user.active = True
+        db_session.add(user)
+        db_session.commit()
+
+        sys.stdout.write('User {0:s} is activated.\n'.format(username))
 
 class ListUsers(Command):
     """List all users."""
@@ -482,6 +523,8 @@ def main():
     shell_manager.add_command('search_template', SearchTemplateManager())
     shell_manager.add_command('import', ImportTimeline())
     shell_manager.add_command('version', GetVersion())
+    shell_manager.add_command('disable_user', DisableUser())
+    shell_manager.add_command("enable_user", EnableUser())
     shell_manager.add_command('runserver',
                               Server(host='127.0.0.1', port=5000))
     shell_manager.add_option(


Test patch: