мелкие правки

This commit is contained in:
Антон
2025-10-04 09:54:55 +03:00
parent 2b5e601387
commit 5346bb2849
13 changed files with 51 additions and 158 deletions
@@ -8,9 +8,7 @@
#include "IExecutor.h"
#include "../DAO/IUserDAO.h"
#include "../exceptions/exception400_bad_request.h"
#include "../exceptions/exception409_conflict.h"
#include "../exceptions/exception422_unprocessable_entity.h"
#include "../exceptions/session_exception.h"
namespace uad
{
@@ -45,7 +43,7 @@ public:
}
catch (const system::system_error& err)
{
throw exception400_bad_request("cannot deserialize json");
throw session_exception(http::status::bad_request, "cannot deserialize json");
}
const std::string login = req_json.as_object().at("login").as_string().c_str();
@@ -53,14 +51,15 @@ public:
if (!ValidateLogin(login) || !ValidatePassword(password))
{
throw exception422_unprocessable_entity(
throw session_exception(
http::status::unprocessable_entity,
"Validations failed. Login should have length from 3 to 50. Password from 5 characters length."s
);
}
if (user_dao_->GetByLogin(login).has_value())
{
throw exception409_conflict("user with login "s + login + " exists"s);
throw session_exception(http::status::conflict, "user with login "s + login + " exists"s);
}
user user;