diff --git a/fence/blueprints/admin.py b/fence/blueprints/admin.py index ed64a9272e..f081d6cb9e 100644 --- a/fence/blueprints/admin.py +++ b/fence/blueprints/admin.py @@ -133,6 +133,20 @@ def delete_user(username): return response +@blueprint.route("/users//soft", methods=["DELETE"]) +@blueprint.route("/user//soft", methods=["DELETE"]) +@admin_login_required +@debug_log +def soft_delete_user(username): + """ + Soft-remove the user by marking it as active=False. + + Returns json object + """ + response = jsonify(admin.soft_delete_user(current_app.scoped_session(), username)) + return response + + @blueprint.route("/users//groups", methods=["GET"]) @blueprint.route("/user//groups", methods=["GET"]) @admin_login_required diff --git a/fence/resources/admin/admin_users.py b/fence/resources/admin/admin_users.py index 57d7bcfb22..6054771729 100644 --- a/fence/resources/admin/admin_users.py +++ b/fence/resources/admin/admin_users.py @@ -335,6 +335,13 @@ def raise_unavailable(gpg_email): logger.info("Done with Google deletions.") +def soft_delete_user(current_session, username): + logger.debug("Soft-delete user.") + usr = us.get_user(current_session, username) + usr.active = False + return us.get_user_info(current_session, usr.username) + + def delete_user(current_session, username): """ Remove a user from both the userdatamodel