generated from Sithas/conan_template
Корректный, хоть и грубый захват JSON'а
This commit is contained in:
@@ -17,7 +17,7 @@ class AuthRegistrationExecutor : public IExecutor<Body, Allocator, ResponseType>
|
||||
|
||||
public:
|
||||
AuthRegistrationExecutor(mysqlx::Session& session,
|
||||
std::shared_ptr<IUserDAO> user_dao)
|
||||
std::shared_ptr<IUserDAO> user_dao)
|
||||
: session_(session), user_dao_(user_dao)
|
||||
{
|
||||
}
|
||||
@@ -31,18 +31,35 @@ public:
|
||||
using namespace boost::beast;
|
||||
|
||||
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();
|
||||
std::string password = json_as_object.at("password").as_string().c_str();
|
||||
try
|
||||
{
|
||||
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.SetLogin(login);
|
||||
user.SetPassword(password);
|
||||
|
||||
user_dao_->GetByLogin(login);
|
||||
|
||||
http::response<ResponseType> res{
|
||||
http::status::ok, req.version()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user