Skip to content

Commit

Permalink
Add command to bin/navuser to remove user
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Nov 2, 2023
1 parent e879e67 commit cdc959c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bin/navuser
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'
)
Expand Down

0 comments on commit cdc959c

Please sign in to comment.