generated from Sithas/conan_template
Корректный, хоть и грубый захват JSON'а
This commit is contained in:
@@ -31,18 +31,35 @@ public:
|
|||||||
using namespace boost::beast;
|
using namespace boost::beast;
|
||||||
|
|
||||||
auto body = req.body();
|
auto body = req.body();
|
||||||
object json_as_object = json::parse(body).as_object();
|
value req_json;
|
||||||
|
|
||||||
std::string login = json_as_object.at("login").as_string().c_str();
|
try
|
||||||
std::string password = json_as_object.at("password").as_string().c_str();
|
{
|
||||||
|
req_json = json::parse(body);
|
||||||
|
}
|
||||||
|
catch (const system::system_error& err)
|
||||||
|
{
|
||||||
|
http::response<ResponseType> res{http::status::bad_request, req.version()};
|
||||||
|
|
||||||
|
res.body() = "{ \"detail\": \"cannot deserialize json\"}";
|
||||||
|
res.set(http::field::content_type, "application/json");
|
||||||
|
res.content_length(res.body().size());
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string login = req_json.as_object().at("login").as_string().c_str();
|
||||||
|
std::string password = req_json.as_object().at("password").as_string().c_str();
|
||||||
|
|
||||||
|
if (user_dao_->GetByLogin(login).has_value())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
User user;
|
User user;
|
||||||
|
|
||||||
user.SetLogin(login);
|
user.SetLogin(login);
|
||||||
user.SetPassword(password);
|
user.SetPassword(password);
|
||||||
|
|
||||||
user_dao_->GetByLogin(login);
|
|
||||||
|
|
||||||
http::response<ResponseType> res{
|
http::response<ResponseType> res{
|
||||||
http::status::ok, req.version()
|
http::status::ok, req.version()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user