emile 1 year ago
parent f6230627cf
commit 585607525d

@ -6,7 +6,8 @@ from osinacore.models import *
from .serializers import *
from django.contrib.auth import authenticate, login
from django.http import JsonResponse
from django.core.exceptions import ObjectDoesNotExist
from django.http import JsonResponse, HttpResponseRedirect
from django.urls import reverse
@api_view(['POST'])
@ -30,6 +31,9 @@ def register_customer(request):
from django.http import JsonResponse, HttpResponseRedirect
from django.urls import reverse
@api_view(['POST'])
def authenticate_customer(request):
if request.method == 'POST':
@ -40,11 +44,8 @@ def authenticate_customer(request):
except User.DoesNotExist:
return JsonResponse({'success': False, 'error': 'User with this email does not exist'})
login(request, user)
return JsonResponse({'success': True, 'user': {
'id': user.id,
'email': user.email,
'username': user.username
}})
# Redirect to the desired URL
redirect_url = 'http://newosina.osinode.com' # Change this URL to your desired redirect URL
return HttpResponseRedirect(redirect_url)

Loading…
Cancel
Save