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('.', '')