From 1a04eda6135f734ce676112007437107c39b07ad Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Wed, 8 Mar 2023 01:00:10 +0530 Subject: [PATCH] fix: make api token only view once (#382) --- apiserver/plane/api/serializers/api_token.py | 8 +++++++- apiserver/plane/api/views/api_token.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apiserver/plane/api/serializers/api_token.py b/apiserver/plane/api/serializers/api_token.py index 247b3f0e7..9c363f895 100644 --- a/apiserver/plane/api/serializers/api_token.py +++ b/apiserver/plane/api/serializers/api_token.py @@ -5,4 +5,10 @@ from plane.db.models import APIToken class APITokenSerializer(BaseSerializer): class Meta: model = APIToken - fields = "__all__" + fields = [ + "label", + "user", + "user_type", + "workspace", + "created_at", + ] diff --git a/apiserver/plane/api/views/api_token.py b/apiserver/plane/api/views/api_token.py index 2508b06ac..a94ffb45c 100644 --- a/apiserver/plane/api/views/api_token.py +++ b/apiserver/plane/api/views/api_token.py @@ -28,7 +28,11 @@ class ApiTokenEndpoint(BaseAPIView): ) serializer = APITokenSerializer(api_token) - return Response(serializer.data, status=status.HTTP_201_CREATED) + # Token will be only vissible while creating + return Response( + {"api_token": serializer.data, "token": api_token.token}, + status=status.HTTP_201_CREATED, + ) except Exception as e: capture_exception(e)