mirror of
https://github.com/AmanTahiliani/PeerNotes.git
synced 2026-08-07 11:55:12 -04:00
add set cookie
This commit is contained in:
@@ -18,7 +18,9 @@ class LoginView(APIView):
|
||||
user = authenticate(username=username, password=password)
|
||||
if user:
|
||||
token, _ = Token.objects.get_or_create(user=user)
|
||||
return Response({"token": token.key})
|
||||
response = Response({"token": token.key}, status=status.HTTP_200_OK)
|
||||
response.set_cookie("token", token.key)
|
||||
return response
|
||||
else:
|
||||
return Response(
|
||||
{"error": "Invalid credentials"},
|
||||
|
||||
@@ -134,3 +134,7 @@ STATIC_URL = "static/"
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
AUTH_USER_MODEL = "api.PeerUser"
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
# CORS_ALLOWED_ORIGINS = [
|
||||
# "http://localhost:5173"
|
||||
# ]
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
Reference in New Issue
Block a user