From cdc959cf81e085949ba6268d5ab15f6f784928d6 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Thu, 2 Nov 2023 07:32:49 +0100 Subject: [PATCH] Add command to bin/navuser to remove user --- bin/navuser | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/navuser b/bin/navuser index 4c6d5a1037..e36ee340a5 100755 --- a/bin/navuser +++ b/bin/navuser @@ -77,6 +77,19 @@ def adduser(args): print(msg % args.login, file=sys.stderr) +def removeuser(args): + try: + args.login.delete() + except args.login.DoesNotExist: + print( + "User %s is not registered, cannot remove" % args.login.login, + file=sys.stderr, + ) + sys.exit(1) + else: + print("User %s has been removed" % args.login.login, file=sys.stderr) + + def adminify(args): action = args.action try: @@ -216,6 +229,12 @@ def parse_args(): ) addparser.set_defaults(func=adduser) + removeparser = subparsers.add_parser('remove', help='Removes a user') + removeparser.set_defaults(func=removeuser) + removeparser.add_argument( + 'login', type=usergetter, help="The login name of the user" + ) + adminifyparser = subparsers.add_parser( 'admin', help='Sets whether an existing user belongs to the admin group' )