soft delete account

This commit is contained in:
rizwanisready
2024-03-26 11:53:24 +05:30
parent e782f43815
commit 64968b13f1
3 changed files with 47 additions and 0 deletions

View File

@@ -32,6 +32,11 @@ urlpatterns = [
views.decode_apple_token,
name="apple_login",
),
path(
"delete-account/",
views.SoftDeletePrincipalAPIView.as_view(),
name="delete_account",
),

View File

@@ -907,3 +907,29 @@ class IAmPrincipalPlayerIDAPIView(APIView):
message=constants.FAILURE,
errors=serializer.errors,
)
class SoftDeletePrincipalAPIView(APIView):
authentication_classes = [JWTAuthentication]
permission_classes = [IsAuthenticated]
"""
Soft delete an IAmPrincipal account.
"""
def delete(self, request, format=None):
principal = request.user
if principal.deleted: # Check if already deleted
return ApiResponse.error(
status=status.HTTP_400_BAD_REQUEST,
message=constants.FAILURE,
errors="Account already deleted.",
)
principal.is_active = False
principal.deleted = True
principal.save()
return ApiResponse.success(
status=status.HTTP_200_OK,
message=constants.SUCCESS,
data="Account has been successfully deleted.",
)

View File

@@ -1,9 +1,13 @@
anyio==4.3.0
asgiref==3.7.2
async-timeout==4.0.3
attrs==23.2.0
autobahn==23.6.2
Automat==22.10.0
certifi==2024.2.2
cffi==1.16.0
channels==4.0.0
channels-redis==4.2.0
charset-normalizer==3.3.2
colorama==0.4.6
colorlog==6.8.2
@@ -24,12 +28,21 @@ django-taggit==5.0.1
django-widget-tweaks==1.5.0
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.1
et-xmlfile==1.1.0
googlemaps==4.10.0
h11==0.14.0
httpcore==1.0.4
httpx==0.27.0
hyperlink==21.0.0
idna==3.6
incremental==22.10.0
lru-dict==1.3.0
msgpack==1.0.8
mysqlclient==2.2.4
numpy==1.26.4
oauthlib==3.2.2
onesignal-sdk==2.0.0
orjson==3.9.15
phonenumbers==8.13.30
pillow==10.2.0
pyasn1==0.5.1
@@ -38,13 +51,16 @@ pycparser==2.21
PyJWT==2.8.0
pyngrok==7.1.2
pyOpenSSL==24.0.0
python-dateutil==2.9.0.post0
python3-openid==3.2.0
pytz==2024.1
PyYAML==6.0.1
redis==5.0.2
requests==2.31.0
requests-oauthlib==1.3.1
service-identity==24.1.0
six==1.16.0
sniffio==1.3.1
sqlparse==0.4.4
stripe==8.2.0
tqdm==4.66.2