|
@@ -5,7 +5,7 @@
|
|
|
#include <fmt/format.h>
|
|
|
#include "Logger.h"
|
|
|
|
|
|
-CNetWork::CNetWork() : m_http_ret(http_f)
|
|
|
+CNetWork::CNetWork() : m_http_ret(HTTPRET::http_f)
|
|
|
{
|
|
|
|
|
|
}
|
|
@@ -26,10 +26,10 @@ HTTPRET CNetWork::Version(std::string& data) {
|
|
|
std::string text = GetUrl("/api/client/v3/version", p, CApp::getSingletonPtr()->GetUserinfo()->access_token);
|
|
|
if (text.empty()) {
|
|
|
|
|
|
- return http_f;
|
|
|
+ return HTTPRET::http_f;
|
|
|
}
|
|
|
data = text.c_str();
|
|
|
- return http_yes;
|
|
|
+ return HTTPRET::http_yes;
|
|
|
}
|
|
|
|
|
|
HTTPRET CNetWork::Refresh(std::string& data) {
|
|
@@ -37,28 +37,28 @@ HTTPRET CNetWork::Refresh(std::string& data) {
|
|
|
std::string text = GetUrl("/api/client/v3/refresh", p, CApp::getSingletonPtr()->GetUserinfo()->access_token);
|
|
|
if (text.empty()) {
|
|
|
|
|
|
- return http_f;
|
|
|
+ return HTTPRET::http_f;
|
|
|
}
|
|
|
data = text.c_str();
|
|
|
- return http_yes;
|
|
|
+ return HTTPRET::http_yes;
|
|
|
}
|
|
|
|
|
|
|
|
|
HTTPRET CNetWork::Auth(std::string& data) {
|
|
|
- return http_yes;
|
|
|
+ return HTTPRET::http_yes;
|
|
|
}
|
|
|
HTTPRET CNetWork::GetServerNode(std::string& data) {
|
|
|
std::vector<cpr::Parameter> p;
|
|
|
std::string text = GetUrl("/api/client/v3/nodes",p,CApp::getSingletonPtr()->GetUserinfo()->access_token);
|
|
|
if (text.empty()) {
|
|
|
|
|
|
- return http_f;
|
|
|
+ return HTTPRET::http_f;
|
|
|
}
|
|
|
|
|
|
data = text.c_str();
|
|
|
|
|
|
|
|
|
- return http_yes;
|
|
|
+ return HTTPRET::http_yes;
|
|
|
}
|
|
|
|
|
|
HTTPRET CNetWork::PostLogin(LPCSTR username, LPCSTR password, std::string& data)
|
|
@@ -68,13 +68,22 @@ HTTPRET CNetWork::PostLogin(LPCSTR username, LPCSTR password, std::string& data)
|
|
|
p.push_back({ "password",password });
|
|
|
std::string text = PostUrl("/api/client/v3/login", p);
|
|
|
if (text.empty()) {
|
|
|
-
|
|
|
- return http_f;
|
|
|
+ if (m_http_status == 445)
|
|
|
+ {
|
|
|
+ return HTTPRET::http_user_expired_at;
|
|
|
+ } else if (m_http_status == 446)
|
|
|
+ {
|
|
|
+ return HTTPRET::http_user_transfer_enable;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return HTTPRET::http_f;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
data = text.c_str();
|
|
|
|
|
|
- return http_yes;
|
|
|
+ return HTTPRET::http_yes;
|
|
|
}
|
|
|
|
|
|
void CNetWork::SetUrl(LPCSTR url)
|
|
@@ -205,6 +214,7 @@ std::string CNetWork::PostUrl(std::string path, std::vector<cpr::Pair> parame, s
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
+
|
|
|
m_http_status = r.status_code;
|
|
|
if (r.error.message.empty())
|
|
|
{
|