Add JWT auth with per-user data isolation and account settings.
Users can register, log in, and manage profile/password in a personal account page; server data is scoped by owner across contacts, maps, tags, and import. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-8
@@ -1,15 +1,23 @@
|
||||
from rest_framework.decorators import api_view
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from core.drf_mixins import JwtAuthMixin
|
||||
from core.access import use_jwt_auth
|
||||
from .services import build_full_graph, build_network_map_graph
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def graph_data(request):
|
||||
return Response(build_full_graph())
|
||||
def _graph_user(request):
|
||||
if use_jwt_auth():
|
||||
return request.user if request.user.is_authenticated else None
|
||||
return None
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def network_map_graph(request):
|
||||
map_id = request.query_params.get('map_id')
|
||||
return Response(build_network_map_graph(map_id))
|
||||
class GraphDataView(JwtAuthMixin, APIView):
|
||||
def get(self, request):
|
||||
return Response(build_full_graph(user=_graph_user(request)))
|
||||
|
||||
|
||||
class NetworkMapGraphView(JwtAuthMixin, APIView):
|
||||
def get(self, request):
|
||||
map_id = request.query_params.get('map_id')
|
||||
return Response(build_network_map_graph(map_id, user=_graph_user(request)))
|
||||
|
||||
Reference in New Issue
Block a user