Skip to content

Commit

Permalink
Merge pull request #3 from AppSecDev/bug_fixes
Browse files Browse the repository at this point in the history
throw when login fails
  • Loading branch information
mattmurp authored Jul 18, 2017
2 parents 6a549c9 + 8923478 commit 8e383f5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ else if(type == LoginType.ASoC) {
}

HttpClient client = new HttpClient();
HttpResponse response = client.postForm(url, headers, params);
JSONObject object = (JSONObject)response.getResponseBodyAsJSON();
HttpResponse response = client.postForm(url, headers, params);

if(response.getResponseCode() == HttpsURLConnection.HTTP_OK || response.getResponseCode() == HttpsURLConnection.HTTP_CREATED) {
if(persist) {
JSONObject object = (JSONObject)response.getResponseBodyAsJSON();
String token = object.getString(TOKEN);
m_authProvider.saveConnection(token);
}
return true;
}
else {
String reason = object.has(MESSAGE) ? object.getString(MESSAGE) : Messages.getMessage("message.unknown"); //$NON-NLS-1$
String reason = response.getResponseBodyAsString() == null ? Messages.getMessage("message.unknown") : response.getResponseBodyAsString(); //$NON-NLS-1$
throw new HttpException(response.getResponseCode(), reason);
}
}
Expand Down

0 comments on commit 8e383f5

Please # to comment.