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