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

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
+5 -6
View File
@@ -10,8 +10,7 @@
#include "../DAO/IUserDAO.h"
#include "../DAO/IAuthDAO.h"
#include "../helpers/helpers.h"
#include "../exceptions/exception400_bad_request.h"
#include "../exceptions/exception422_unprocessable_entity.h"
#include "../exceptions/session_exception.h"
namespace uad
{
@@ -48,7 +47,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");
}
@@ -57,14 +56,14 @@ public:
if (login.empty() || password.empty())
{
throw exception422_unprocessable_entity("Login or password are empty"s);
throw session_exception(http::status::unprocessable_entity, "Login or password are empty"s);
}
const std::optional<user> maybe_user = user_dao_->GetByLogin(login);
if (!maybe_user.has_value() || maybe_user.value().hashed_password != HashPassword(password))
if (!maybe_user.has_value() && maybe_user.value().hashed_password != HashPassword(password))
{
throw exception422_unprocessable_entity("Incorrect login or password");
throw session_exception(http::status::forbidden,"Incorrect login or password");
}
const std::string token = GenerateUUID();
auth_dao_->Login(maybe_user.value().uuid, token);