Skip to content

Commit

Permalink
wip: draft soft-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlukasse committed Oct 21, 2024
1 parent 3183332 commit 8f8fdf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fence/blueprints/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ def delete_user(username):
return response


@blueprint.route("/users/<username>/soft", methods=["DELETE"])
@blueprint.route("/user/<username>/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/<username>/groups", methods=["GET"])
@blueprint.route("/user/<username>/groups", methods=["GET"])
@admin_login_required
Expand Down
10 changes: 10 additions & 0 deletions fence/resources/admin/admin_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ def raise_unavailable(gpg_email):
logger.info("Done with Google deletions.")


def soft_delete_user(current_session, username):
"""
Soft-remove the user by marking it as active=False.
"""
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
Expand Down

0 comments on commit 8f8fdf7

Please sign in to comment.