Skip to content

Commit

Permalink
--no-logout on synadm user modify
Browse files Browse the repository at this point in the history
Fixes: #153
  • Loading branch information
JacksonChen666 committed Jan 22, 2025
1 parent 8a54a29 commit 285d9fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion synadm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ def user_login(self, user_id, expire_days, expire, _expire_ts):
user_id=user_id)

def user_modify(self, user_id, password, display_name, threepid,
avatar_url, admin, deactivation, user_type, lock):
avatar_url, admin, deactivation, user_type, lock,
logout_devices):
""" Create or update information about a given user
The threepid argument must be passed as a tuple in a tuple (which is
Expand Down Expand Up @@ -631,6 +632,8 @@ def user_modify(self, user_id, password, display_name, threepid,
if user_type:
data.update({"user_type": None if user_type == 'null' else
user_type})
if logout_devices:
data.update({"logout_devices": logout_devices})
return self.query("put", "v2/users/{user_id}", data=data,
user_id=user_id)

Expand Down
14 changes: 10 additions & 4 deletions synadm/cli/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,10 @@ def name_extra(self):
@optgroup.group(cls=UserModifyOptionGroup)
@optgroup.option(
"--password-prompt", "-p", is_flag=True,
help="Set password interactively.")
help="Set password interactively. See also the --no-logout option.")
@optgroup.option(
"--password", "-P", type=str,
help="Set password on command line.")
help="Set password on command line. See also the --no-logout option.")
@optgroup.option(
"--display-name", "-n", type=str,
help="Set display name. defaults to the value of user_id")
Expand Down Expand Up @@ -432,6 +432,11 @@ def name_extra(self):
is omitted when modifying an existing user, the user-type will not be
manipulated. If the --user-type option is omitted when creating a new user,
a regular user will be created.""")
@optgroup.option(
"--no-logout", "logout_devices", type=bool, default=False, is_flag=True,
help="""When setting a password, the user is logged out on all devices
by default (unspecified). When --no-logout is specified, devices are not
logged out even when the password is changed.""")
@optgroup.option(
"--lock/--unlock", "-l/-L", default=None, show_default=False,
help="""Whether to lock or unlock the account, preventing or allowing
Expand All @@ -440,7 +445,7 @@ def name_extra(self):
@click.pass_context
def modify(ctx, helper, user_id, password, password_prompt, display_name,
threepid, clear_threepids, avatar_url, admin, deactivation,
user_type, lock):
user_type, lock, logout_devices):
""" Create or modify a local user. Provide matrix user ID (@user:server)
as argument.
"""
Expand Down Expand Up @@ -503,7 +508,8 @@ def modify(ctx, helper, user_id, password, password_prompt, display_name,
avatar_url,
admin,
deactivation,
'null' if user_type == 'regular' else user_type, lock
'null' if user_type == 'regular' else user_type, lock,
logout_devices
)
if modified is None:
click.echo("User could not be modified/created.")
Expand Down

0 comments on commit 285d9fc

Please sign in to comment.