diff --git a/osinaweb/osinacore/api/views.py b/osinaweb/osinacore/api/views.py index 49ae5b94..38f86c93 100644 --- a/osinaweb/osinacore/api/views.py +++ b/osinaweb/osinacore/api/views.py @@ -6,7 +6,6 @@ from osinacore.models import * from .serializers import * from django.contrib.auth import authenticate, login from django.http import JsonResponse -from django.contrib.auth import AuthenticationFailed @api_view(['POST']) @@ -33,13 +32,9 @@ def authenticate_customer(request): if request.method == 'POST': email = request.POST.get('email') password = request.POST.get('password') - try: - user = authenticate(request, username=email, password=password) - if user is not None: - login(request, user) - return JsonResponse({'success': True}) - else: - return JsonResponse({'success': False, 'error': 'Invalid credentials'}) - except AuthenticationFailed as e: - # Return the error message provided by the authentication system - return JsonResponse({'success': False, 'error': str(e)}) \ No newline at end of file + user = authenticate(request, email=email, password=password) + if user is not None: + login(request, user) + return JsonResponse({'success': True}) + else: + return JsonResponse({'success': False, 'error': 'Invalid credentials'}) \ No newline at end of file