| 371 | } |
| 372 | |
| 373 | void insertSession( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer::Request > request ) |
| 374 | { |
| 375 | print_request_info( request ); |
| 376 | |
| 377 | try |
| 378 | { |
| 379 | auto json = nlohmann::json::parse( request->content ); |
| 380 | |
| 381 | std::string sId = json["sId"]; |
| 382 | uint32_t accountId = json["accountId"].get< uint32_t >(); |
| 383 | std::string secret = json["secret"]; |
| 384 | |
| 385 | // reloadConfig(); |
| 386 | if( m_config.global.general.serverSecret != secret ) |
| 387 | { |
| 388 | std::string json_string = "{\"result\":\"invalid_secret\"}"; |
| 389 | *response << buildHttpResponse( 403, json_string, JSON ); |
| 390 | } |
| 391 | else |
| 392 | { |
| 393 | g_sapphireAPI.insertSession( accountId, sId ); |
| 394 | std::string json_string = "{\"result\":\"success\"}"; |
| 395 | *response << buildHttpResponse( 200, json_string, JSON ); |
| 396 | } |
| 397 | } |
| 398 | catch( exception& e ) |
| 399 | { |
| 400 | *response << buildHttpResponse( 500 ); |
| 401 | Logger::error( e.what() ); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | void checkNameTaken( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer::Request > request ) |
| 406 | { |
nothing calls this directly
no test coverage detected