Repository: techmatters/terraso-backend

Issue:
Remove /auth/user endpoint
<!--
Use a concise title that describes the problem. Include key words from error messages.
Bad: Problem with newsletter form
Good: Newsletter form missing email address field

Bad: Issue with website
Good: Footer missing from homepage
-->

## Description
Clients in general should use the graph QL interface to gather and manipulate data, right now this enpoint is conflicting with that. It was created to provide the initial authenticated user data, but using the data provided by the JWT token this is not needed anymore.


Discussion:

Resolving patch:
diff --git a/terraso_backend/apps/auth/urls.py b/terraso_backend/apps/auth/urls.py
--- a/terraso_backend/apps/auth/urls.py
+++ b/terraso_backend/apps/auth/urls.py
@@ -4,7 +4,6 @@
 from apps.auth.views import (
     AppleAuthorizeView,
     AppleCallbackView,
-    CheckUserView,
     GoogleAuthorizeView,
     GoogleCallbackView,
     RefreshAccessTokenView,
@@ -26,5 +25,4 @@
         name="google-callback",
     ),
     path("tokens", csrf_exempt(RefreshAccessTokenView.as_view()), name="tokens"),
-    path("user", csrf_exempt(CheckUserView.as_view()), name="user"),
 ]
diff --git a/terraso_backend/apps/auth/views.py b/terraso_backend/apps/auth/views.py
--- a/terraso_backend/apps/auth/views.py
+++ b/terraso_backend/apps/auth/views.py
@@ -5,7 +5,6 @@
 from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
 from django.views import View
 
-from .mixins import AuthenticationRequiredMixin
 from .providers import AppleProvider, GoogleProvider
 from .services import AccountService, JWTService
 
@@ -130,18 +129,3 @@ def post(self, request, *args, **kwargs):
                 "refresh_token": refresh_token,
             }
         )
-
-
-class CheckUserView(AuthenticationRequiredMixin, View):
-    def get(self, request, *args, **kwargs):
-        user = request.user
-        return JsonResponse(
-            {
-                "user": {
-                    "email": user.email,
-                    "first_name": user.first_name,
-                    "last_name": user.last_name,
-                    "profile_image": user.profile_image,
-                }
-            }
-        )


Test patch:
diff --git a/terraso_backend/tests/auth/test_views.py b/terraso_backend/tests/auth/test_views.py
--- a/terraso_backend/tests/auth/test_views.py
+++ b/terraso_backend/tests/auth/test_views.py
@@ -226,23 +226,3 @@ def test_post_refresh_token_inactive_user(client, refresh_tokens_url, user, refr
 
     tokens_data = response.json()
     assert tokens_data["error"] == "User not found"
-
-
-def test_get_user_information_not_logged_in(client):
-    url = reverse("terraso_auth:user")
-    response = client.get(url)
-
-    assert response.status_code == 401
-    assert "error" in response.json()
-
-
-def test_get_user_information(client, user, access_token):
-    url = reverse("terraso_auth:user")
-    response = client.get(url, HTTP_AUTHORIZATION=f"Bearer {access_token}")
-
-    assert response.status_code == 200
-
-    user_data = response.json()["user"]
-    assert user_data["email"] == user.email
-    assert user_data["first_name"] == user.first_name
-    assert user_data["last_name"] == user.last_name