mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 10:05:21 +00:00
@ -1,4 +1,6 @@
|
|||||||
"""Account view """
|
"""Account view """
|
||||||
|
from notifications.utils import remove_fcm_token
|
||||||
|
|
||||||
"""Django import"""
|
"""Django import"""
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from rest_framework import viewsets, status, views
|
from rest_framework import viewsets, status, views
|
||||||
@ -531,6 +533,10 @@ class LogoutAPIView(views.APIView):
|
|||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
|
remove_fcm_token(
|
||||||
|
request.auth.payload['user_id'],
|
||||||
|
request.META['HTTP_AUTHORIZATION'].split(" ")[1],
|
||||||
|
request.data.get('registration_id', ""))
|
||||||
logout(request)
|
logout(request)
|
||||||
request.session.flush()
|
request.session.flush()
|
||||||
return custom_response(SUCCESS_CODE['3020'], response_status=status.HTTP_200_OK)
|
return custom_response(SUCCESS_CODE['3020'], response_status=status.HTTP_200_OK)
|
||||||
|
@ -15,3 +15,13 @@ def register_fcm_token(user_id, registration_id, device_id, device_type):
|
|||||||
'registration_id': registration_id})
|
'registration_id': registration_id})
|
||||||
return device
|
return device
|
||||||
|
|
||||||
|
|
||||||
|
def remove_fcm_token(user_id: int, access_token: str, registration_id) -> None:
|
||||||
|
"""
|
||||||
|
remove access_token and registration_token
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# remove fcm token for this device
|
||||||
|
FCMDevice.objects.filter(user_id=user_id).delete()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
@ -11,7 +11,7 @@ from web_admin.views import ArticleViewSet
|
|||||||
# initiate router
|
# initiate router
|
||||||
router = routers.SimpleRouter()
|
router = routers.SimpleRouter()
|
||||||
|
|
||||||
router.register('articles', ArticleViewSet, basename='articles')
|
router.register('article', ArticleViewSet, basename='article')
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('api/v1/', include(router.urls)),
|
path('api/v1/', include(router.urls)),
|
||||||
|
@ -33,6 +33,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||||||
SECRET_KEY = os.getenv('SECRET_KEY')
|
SECRET_KEY = os.getenv('SECRET_KEY')
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = os.getenv('DEBUG')
|
DEBUG = os.getenv('DEBUG')
|
||||||
|
|
||||||
|
# cors allow setting
|
||||||
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
|
|
||||||
# allow all host
|
# allow all host
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
@ -185,8 +189,6 @@ USE_TZ = True
|
|||||||
# cors header settings
|
# cors header settings
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
|
||||||
# cors allow setting
|
|
||||||
CORS_ORIGIN_ALLOW_ALL = True
|
|
||||||
|
|
||||||
# cors allow method
|
# cors allow method
|
||||||
CORS_ALLOW_METHODS = (
|
CORS_ALLOW_METHODS = (
|
||||||
|
Reference in New Issue
Block a user