# HG changeset patch # User Mads Kiilerich # Date 2020-08-03 20:29:20 # Node ID a2d8c1f616575a671219e2e752449a2748061dd1 # Parent d442d8395b75a6a9fbbd2d571b5e75a3d62f81ba ssh: update authorized_keys after deleting a user with ssh keys This fixes a minor problem with minimal impact: The authorized_keys entries would fail anyway when the referenced user wasn't found ... and the entries would go away next time authorized_keys for some reason were updated. Reported by Louis Bertrand. diff --git a/kallithea/controllers/admin/users.py b/kallithea/controllers/admin/users.py --- a/kallithea/controllers/admin/users.py +++ b/kallithea/controllers/admin/users.py @@ -182,6 +182,7 @@ class UsersController(BaseController): def delete(self, id): usr = User.get_or_404(id) + has_ssh_keys = bool(usr.ssh_keys) try: UserModel().delete(usr) Session().commit() @@ -192,6 +193,9 @@ class UsersController(BaseController): log.error(traceback.format_exc()) h.flash(_('An error occurred during deletion of user'), category='error') + else: + if has_ssh_keys: + SshKeyModel().write_authorized_keys() raise HTTPFound(location=url('users')) def _get_user_or_raise_if_default(self, id):