mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-01 05:36:02 -04:00
Add an admin option to shared secret registration
This commit is contained in:
parent
caf33b2d9b
commit
651faee698
4 changed files with 58 additions and 27 deletions
|
@ -42,6 +42,7 @@ def request_registration(user, password, server_location, shared_secret, admin=F
|
|||
"password": password,
|
||||
"mac": mac,
|
||||
"type": "org.matrix.login.shared_secret",
|
||||
"admin": admin,
|
||||
}
|
||||
|
||||
server_location = server_location.rstrip("/")
|
||||
|
@ -73,7 +74,7 @@ def request_registration(user, password, server_location, shared_secret, admin=F
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def register_new_user(user, password, server_location, shared_secret):
|
||||
def register_new_user(user, password, server_location, shared_secret, admin):
|
||||
if not user:
|
||||
try:
|
||||
default_user = getpass.getuser()
|
||||
|
@ -104,7 +105,14 @@ def register_new_user(user, password, server_location, shared_secret):
|
|||
print "Passwords do not match"
|
||||
sys.exit(1)
|
||||
|
||||
request_registration(user, password, server_location, shared_secret)
|
||||
if not admin:
|
||||
admin = raw_input("Make admin [no]: ")
|
||||
if admin in ("y", "yes", "true"):
|
||||
admin = True
|
||||
else:
|
||||
admin = False
|
||||
|
||||
request_registration(user, password, server_location, shared_secret, bool(admin))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -124,6 +132,11 @@ if __name__ == "__main__":
|
|||
default=None,
|
||||
help="New password for user. Will prompt if omitted.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a", "--admin",
|
||||
action="store_true",
|
||||
help="Register new user as an admin. Will prompt if omitted.",
|
||||
)
|
||||
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument(
|
||||
|
@ -156,4 +169,4 @@ if __name__ == "__main__":
|
|||
else:
|
||||
secret = args.shared_secret
|
||||
|
||||
register_new_user(args.user, args.password, args.server_url, secret)
|
||||
register_new_user(args.user, args.password, args.server_url, secret, args.admin)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue