From ebba88fe62bdae948af2aba8539cf796d5baf85c Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Tue, 10 Oct 2023 11:26:42 +0200 Subject: [PATCH] implement user reactivate --- synadm/api.py | 9 ++++++--- synadm/cli/user.py | 12 +++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/synadm/api.py b/synadm/api.py index d89f4a19..b3adc66f 100644 --- a/synadm/api.py +++ b/synadm/api.py @@ -668,9 +668,12 @@ def user_reactivate(self, user_id, password=None): password (str or None): A password. Required under certain conditions. """ - # TODO - # TODO: handling errors when password is required? - pass + data = { + "deactivated": False + } + if password != None: + data["password"] = password + return self._user_modify_api(user_id, data) def user_set_lock(self, user_id, locked): """ diff --git a/synadm/cli/user.py b/synadm/cli/user.py index 5be2cc59..a292deea 100644 --- a/synadm/cli/user.py +++ b/synadm/cli/user.py @@ -558,12 +558,14 @@ def set_display_name(helper, user_id, display_name): @user.command() @click.argument("user_id", type=str) +# TODO: check compatibility with --batch +@click.password_option(required=False, +help="""The new password to set to. This is required when reactivating a +user on a Synapse installation with passwords enabled.""") @click.pass_obj -def reactivate(helper, user_id): - # TODO - # TODO: does this require a password? merge into password? user - # experience? - pass +def reactivate(helper, user_id, password): + result = helper.api.user_reactivate(user_id, password) + helper.output(result) @user.command()