about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn_auth/auth/authorisation/resources/views.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py
index 01373ca..76cf416 100644
--- a/gn_auth/auth/authorisation/resources/views.py
+++ b/gn_auth/auth/authorisation/resources/views.py
@@ -364,6 +364,11 @@ def assign_role_to_user(resource_id: UUID) -> Response:
 @require_oauth("profile group resource role")
 def unassign_role_to_user(resource_id: UUID) -> Response:
     """Unassign a role on the specified resource from a user."""
+    warnings.warn(
+        f"The function `{__name__}.unassign_role_to_user` is deprecated. Please "
+        " use `gn_auth.auth.authorisation.users.views.revoke_user_role`",
+        DeprecationWarning,
+        stacklevel=2)
     with require_oauth.acquire("profile group resource role") as _token:
         try:
             form = request_json()
@@ -385,7 +390,15 @@ def unassign_role_to_user(resource_id: UUID) -> Response:
         except AssertionError as aserr:
             raise AuthorisationError(aserr.args[0]) from aserr
 
-        return jsonify(with_db_connection(__assign__))
+        new_uri = url_for(
+            "oauth2.users.revoke_user_role",
+            user_id=str(_token.user.user_id)
+        ).replace(str(_token.user.user_id), "<uuid:user_id>")
+        return jsonify({
+            **with_db_connection(__assign__),
+            "DeprecationWarning": (
+                "This endpoint is deprecated and will be removed. Please use "
+                f"the {new_uri} endpoint.")})
 
 def __public_view_params__(cursor, user_id, resource_id):
     ignore = (str(user_id),)