From ceec6ce5f47868d3a0f6426469dd4f12701b4738 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 10 Sep 2018 19:32:56 +0200 Subject: [PATCH] add --regular-user flag to registration script --- scripts/register_new_matrix_user | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/register_new_matrix_user b/scripts/register_new_matrix_user index 8c3d429351..ebda158fb1 100755 --- a/scripts/register_new_matrix_user +++ b/scripts/register_new_matrix_user @@ -133,7 +133,7 @@ def register_new_user(user, password, server_location, shared_secret, admin): print "Passwords do not match" sys.exit(1) - if not admin: + if admin is None: admin = raw_input("Make admin [no]: ") if admin in ("y", "yes", "true"): admin = True @@ -163,7 +163,12 @@ if __name__ == "__main__": parser.add_argument( "-a", "--admin", action="store_true", - help="Register new user as an admin. Will prompt if omitted.", + help="Register new user as an admin. Will prompt if --regular-user is not set.", + ) + parser.add_argument( + "--regular-user", + action="store_true", + help="Register new user as a regular user.", ) group = parser.add_mutually_exclusive_group(required=True) @@ -197,4 +202,10 @@ if __name__ == "__main__": else: secret = args.shared_secret - register_new_user(args.user, args.password, args.server_url, secret, args.admin) + if args.admin and args.regular_user: + print "Both --admin and --regular-user are set, choose either." + sys.exit(1) + + admin = True if args.admin else False if args.regular_user else None + + register_new_user(args.user, args.password, args.server_url, secret, admin)