MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / post

Method post

apps/accounts/api_views.py:106–123  ·  view source on GitHub ↗
(self, request, *args, **kwargs)

Source from the content-addressed store, hash-verified

104
105class TokenRefreshView(TokenRefreshView):
106 def post(self, request, *args, **kwargs):
107 # Custom logic here
108 if not network_access_allowed(request, "UI"):
109 # Log blocked token refresh attempt due to network restrictions
110 from core.utils import log_system_event
111 client_ip = request.META.get('REMOTE_ADDR', 'unknown')
112 user_agent = request.META.get('HTTP_USER_AGENT', 'unknown')
113 logger.info(f"Token refresh blocked by network policy: ip={client_ip} ua={user_agent}")
114 log_system_event(
115 event_type='login_failed',
116 user='token_refresh',
117 client_ip=client_ip,
118 user_agent=user_agent,
119 reason='Network access denied (token refresh)',
120 )
121 return Response({"error": "Unauthorized"}, status=status.HTTP_403_FORBIDDEN)
122
123 return super().post(request, *args, **kwargs)
124
125
126@csrf_exempt # In production, consider CSRF protection strategies or ensure this endpoint is only accessible when no superuser exists.

Calls 3

network_access_allowedFunction · 0.90
log_system_eventFunction · 0.90
getMethod · 0.45