From 7ebabbb5f6144ce73d78fceb1ed342074faea279 Mon Sep 17 00:00:00 2001 From: Darksider3 Date: Wed, 23 Oct 2019 15:02:48 +0200 Subject: [PATCH] EditUsers: Implement --remove flag --- private/editUsers.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/private/editUsers.py b/private/editUsers.py index eaa6ddc..2483ca8 100755 --- a/private/editUsers.py +++ b/private/editUsers.py @@ -52,6 +52,21 @@ if __name__ == "__main__": exit(1) CurrentUser = DB.safequery("SELECT * FROM `applications` WHERE `username`=?", tuple([args.user]))[0] + if args.remove: + print(f"Removing {args.user} from the system and the database...") + try: + DB.removeApplicantFromDBperUsername(args.user) + print(f"Purged from the DB") + if CurrentUser["status"] == 1: + Sysctl.remove_user(args.user) + print(f"Purged from the system") + else: + print(f"{args.user} wasn't approved before, therefore not deleting from system itself.") + except lib.UserExceptions.General as e: + print(f"{e}") + exit(1) + print("Success.") + exit(0) if args.sshpubkey: if not lib.validator.checkSSHKey(args.sshpubkey): print(f"Pubkey {args.sshpubkey} isn't valid.")