MCPcopy Create free account
hub / github.com/chrxh/alien / login

Method login

source/Network/NetworkService.cpp:152–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152bool NetworkService::login(LoginErrorCode& errorCode, std::string const& userName, std::string const& password, UserInfo const& userInfo)
153{
154 log(Priority::Important, "network: login user '" + userName + "'");
155
156 httplib::SSLClient client(_serverAddress);
157 configureClient(client);
158
159 httplib::Params params;
160 params.emplace("userName", userName);
161 params.emplace("password", password);
162 if (userInfo.gpu) {
163 params.emplace("gpu", *userInfo.gpu);
164 }
165
166 try {
167 auto result = executeRequest([&] { return client.Post("/alien-server/login.php", params); });
168
169 auto boolResult = parseBoolResult(result->body);
170 if (boolResult) {
171 _loggedInUserName = userName;
172 _password = password;
173 }
174
175 errorCode = 0;
176 std::stringstream stream(result->body);
177 boost::property_tree::ptree tree;
178 boost::property_tree::read_json(stream, tree);
179 errorCode = tree.get<LoginErrorCode>("errorCode");
180
181 return boolResult;
182 } catch (...) {
183 logNetworkError();
184 return false;
185 }
186}
187
188bool NetworkService::logout()
189{

Callers 3

processRequestMethod · 0.80
onActivateUserMethod · 0.80
onNewPasswordMethod · 0.80

Calls 6

logFunction · 0.85
configureClientFunction · 0.85
executeRequestFunction · 0.85
parseBoolResultFunction · 0.85
logNetworkErrorFunction · 0.85
PostMethod · 0.80

Tested by

no test coverage detected