Pass login error message to client

This commit is contained in:
Tanner Collin 2019-05-23 12:41:59 -06:00
parent 652ef3fb8d
commit 77d961376e

View File

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