From 77d961376e06d3e240856f8539c67c1295e1bb0a Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 23 May 2019 12:41:59 -0600 Subject: [PATCH] Pass login error message to client --- authserver/authserver/api/customroutes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/authserver/authserver/api/customroutes.py b/authserver/authserver/api/customroutes.py index 918fa71..874a6fa 100644 --- a/authserver/authserver/api/customroutes.py +++ b/authserver/authserver/api/customroutes.py @@ -51,9 +51,13 @@ def login(request): status=status.HTTP_400_BAD_REQUEST) post_data = {'user_name': username, 'web_pw': password, 'SubmitButton': 'Login'} - res = requests.post(PROTOSPACE_LOGIN_PAGE, post_data, allow_redirects=False) + try: + res = requests.post(PROTOSPACE_LOGIN_PAGE, post_data, allow_redirects=False, timeout=2) + except: + return Response({'error': 'Problem reaching my.protospace.ca'}, status=status.HTTP_503_SERVICE_UNAVAILABLE) + if res.status_code == requests.codes.ok: - return Response({'error': 'Invalid Credentials'}, status=status.HTTP_404_NOT_FOUND) + return Response({'error': 'Invalid username / password'}, status=status.HTTP_404_NOT_FOUND) lockout_username = username.replace('.', '')