Show more useful error on login failure

merge/2021-11-19
kaetemi 3 years ago
parent 088171a589
commit 939836b5bb
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -63,6 +63,8 @@ public:
/// Disconnect if connected (otherwise does nothing)
void disconnect();
const char *lastError() { return &m_ErrorBuf[0]; }
protected:
/// Helper
@ -78,6 +80,8 @@ private:
std::vector<uint8> _ReceiveBuffer;
std::string _Auth; // must be kept here because curl only stores the char pointer
std::vector<char> m_ErrorBuf;
};
extern CCurlHttpClient CurlHttpClient;

@ -124,15 +124,17 @@ bool CCurlHttpClient::sendRequest(const std::string& methodWB, const std::string
curl_easy_setopt(_Curl, CURLOPT_WRITEFUNCTION, CCurlHttpClient::writeDataFromCurl);
curl_easy_setopt(_Curl, CURLOPT_WRITEDATA, this);
char errorbuf [CURL_ERROR_SIZE+1];
curl_easy_setopt(_Curl, CURLOPT_ERRORBUFFER, errorbuf);
if (!m_ErrorBuf.size())
m_ErrorBuf.resize(CURL_ERROR_SIZE + 1);
m_ErrorBuf[0] = '\0';
curl_easy_setopt(_Curl, CURLOPT_ERRORBUFFER, &m_ErrorBuf[0]);
// Send
CURLcode res = curl_easy_perform(_Curl);
if (res != 0)
{
if (verbose)
nlwarning(errorbuf);
nlwarning(&m_ErrorBuf[0]);
return false;
}

@ -2832,7 +2832,7 @@ string checkLogin(const string &login, const string &password, const string &cli
{
// ask server for salt
if(!HttpClient.sendGet(url + "?cmd=ask&cp=2&login=" + login + "&lg=" + ClientCfg.LanguageCode, "", pPM->isVerboseLog()))
return "Can't send (error code 60)";
return std::string("Can't send (error code 60) ") + HttpClient.lastError();
if(pPM->isVerboseLog()) nlinfo("Sent request for password salt");

Loading…
Cancel
Save