generated from Sithas/conan_template
мелкие правки
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user