generated from Sithas/conan_template
Compare commits
1 Commits
bea195ca80
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e48d3f30cb |
@@ -5,6 +5,8 @@
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
#include <boost/uuid.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
@@ -38,6 +40,8 @@ public:
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
// BOOST_LOG_TRIVIAL(info) << "Auth/Login - Request";
|
||||
|
||||
const auto body = req.body();
|
||||
value req_json;
|
||||
|
||||
@@ -47,6 +51,7 @@ public:
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Login - Error 400";
|
||||
throw session_exception(http::status::bad_request, "cannot deserialize json");
|
||||
}
|
||||
|
||||
@@ -56,6 +61,7 @@ public:
|
||||
|
||||
if (login.empty() || password.empty())
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Login - Error 422";
|
||||
throw session_exception(http::status::unprocessable_entity, "Login or password are empty"s);
|
||||
}
|
||||
|
||||
@@ -63,6 +69,7 @@ public:
|
||||
|
||||
if (!maybe_user.has_value() && maybe_user.value().hashed_password != HashPassword(password))
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Login - Error 403";
|
||||
throw session_exception(http::status::forbidden,"Incorrect login or password");
|
||||
}
|
||||
const std::string token = GenerateUUID();
|
||||
@@ -78,6 +85,8 @@ public:
|
||||
res.set(http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
// BOOST_LOG_TRIVIAL(info) << "Auth/Login - Success - 200";
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
#include <boost/uuid.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
@@ -35,6 +37,8 @@ public:
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
// BOOST_LOG_TRIVIAL(info) << "Auth/Logout - Request";
|
||||
|
||||
const auto body = req.body();
|
||||
value req_json;
|
||||
|
||||
@@ -44,6 +48,7 @@ public:
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Login - Error 500";
|
||||
throw session_exception(http::status::internal_server_error, "cannot deserialize json"s);
|
||||
}
|
||||
|
||||
@@ -51,6 +56,7 @@ public:
|
||||
|
||||
if (!auth_dao_->Logout(token))
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Login - Error 400";
|
||||
throw session_exception(http::status::bad_request, "token is not authorized"s);
|
||||
}
|
||||
|
||||
@@ -60,6 +66,8 @@ public:
|
||||
res.set(http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
// BOOST_LOG_TRIVIAL(info) << "Auth/Login - Success 200";
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <regex>
|
||||
#include <boost/json.hpp>
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
@@ -32,6 +34,8 @@ public:
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
// BOOST_LOG_TRIVIAL(info) << "Auth/Registration - Request";
|
||||
|
||||
const auto& body = req.body();
|
||||
value req_json;
|
||||
|
||||
@@ -41,6 +45,7 @@ public:
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Logout - Error 400";
|
||||
throw session_exception(http::status::bad_request, "cannot deserialize json");
|
||||
}
|
||||
|
||||
@@ -49,6 +54,7 @@ public:
|
||||
|
||||
if (!ValidateLogin(login) || !ValidatePassword(password))
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Logout - Error 422";
|
||||
throw session_exception(
|
||||
http::status::unprocessable_entity,
|
||||
"Validations failed. Login should have length from 3 to 50. Password from 5 characters length."s
|
||||
@@ -57,6 +63,7 @@ public:
|
||||
|
||||
if (user_dao_->GetByLogin(login).has_value())
|
||||
{
|
||||
// BOOST_LOG_TRIVIAL(error) << "Auth/Logout - Error 409";
|
||||
throw session_exception(http::status::conflict, "user with login "s + login + " exists"s);
|
||||
}
|
||||
|
||||
@@ -87,6 +94,8 @@ public:
|
||||
res.set(http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
// BOOST_LOG_TRIVIAL(info) << "Auth/Logout - Created 201";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
#ifdef WIN32
|
||||
#define _WIN32_WINNT 0x0602
|
||||
#include <sdkddkver.h>
|
||||
#endif
|
||||
|
||||
@@ -63,7 +64,7 @@ int main(int argc, char* argv[])
|
||||
net::signal_set signals(ioc, SIGINT, SIGTERM);
|
||||
signals.async_wait([&](beast::error_code const&, int) { ioc.stop(); });
|
||||
|
||||
BOOST_LOG_TRIVIAL(error) << "Приложение запущено";
|
||||
BOOST_LOG_TRIVIAL(info) << "Приложение запущено";
|
||||
|
||||
std::vector<std::thread> v;
|
||||
v.reserve(threads - 1);
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include <memory>
|
||||
#include <boost/beast.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup/file.hpp>
|
||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user