diff --git a/client/internal/gui/src/EntryWindow.cpp b/client/internal/gui/src/EntryWindow.cpp index a781f175874b489e7a4dfe94d360da78c6569577..9a0a4dbccdef2d2f2c13fb4880b47c8130d65977 100644 --- a/client/internal/gui/src/EntryWindow.cpp +++ b/client/internal/gui/src/EntryWindow.cpp @@ -23,7 +23,7 @@ void EntryWindow::setupUi(QMainWindow *EntryWindow) { verticalLayout = new QVBoxLayout(centralwidget); introLabel = new QLabel(centralwidget); - introLabel->setText("Добро пожаловать в Noiseground!"); + introLabel->setText("Добро пожаловать в SourcedOut!"); introLabel->setGeometry(QRect(140, 200, 331, 31)); verticalLayout->addWidget(introLabel, 0, Qt::AlignHCenter); diff --git a/client/internal/gui/src/SignUpDialog.cpp b/client/internal/gui/src/SignUpDialog.cpp index 1cdc2a31a2432c3fc72eb885c5153fdc999325f1..7d34cb5ba695004fe21807a2f80d1a8079c8e2f6 100644 --- a/client/internal/gui/src/SignUpDialog.cpp +++ b/client/internal/gui/src/SignUpDialog.cpp @@ -87,7 +87,11 @@ void SignUpDialog::on_signUpButton_clicked() { close(); break; case 403: - QMessageBox::warning(this, "Регистрация невозможна", "Логин уже занят!"); + QMessageBox::warning(this, "Регистрация невозможна", "Произошла ошибка! Попробуйте ещё раз. \n" + "\n" + "Логин должен быть в виде: example@mail.ru \n" + "Имя от 3 до 20 символов \n" + "Пароль от 8 до 30 символов"); break; default: QMessageBox::critical(this, "Регистрация невозможна!", "Нет соединения с сервером!"); diff --git a/client/internal/gui/src/SolutionsWindow.cpp b/client/internal/gui/src/SolutionsWindow.cpp index ccbc7e528bf2906a61430dcc718cf120443a09ff..854f5ff27df7a4732292e7230e7edc56201e4ef1 100644 --- a/client/internal/gui/src/SolutionsWindow.cpp +++ b/client/internal/gui/src/SolutionsWindow.cpp @@ -37,7 +37,7 @@ void SolutionsWindow::setupUi(QMainWindow *SolutionsWindow) { filename = new QLabel(this); chooseFileButton = new QPushButton(this); - chooseFileButton->setText(QString::fromUtf8("Выбирите файл")); + chooseFileButton->setText(QString::fromUtf8("Выберите файл")); sendButton = new QPushButton(this); sendButton->setText(QString::fromUtf8("Отправить")); diff --git a/server/internal/httpServer/src/UserManager.cpp b/server/internal/httpServer/src/UserManager.cpp index b94bca7717df6c8a335dfe5cb2410c7acc26dbb4..b9e68e34a9ccb9b41aae8e34c7c15f278327deb0 100644 --- a/server/internal/httpServer/src/UserManager.cpp +++ b/server/internal/httpServer/src/UserManager.cpp @@ -1,6 +1,7 @@ #include "UserManager.h" #include "TmpUserService.h" +#include "ServiceExceptions.h" #include "Utils.h" UserManager::UserManager() : serializer(std::make_shared()), userService(std::make_shared()) {} @@ -13,7 +14,7 @@ http::message_generator UserManager::loginUser(http::request try { std::tie(login, password) = serializer->deserialUserData(req.body()); } catch (...) { - return getBadRequest(req, "Something went wrong!"); + return getBadRequest(req, "Неправильные параметры!"); } User user; @@ -40,16 +41,21 @@ http::message_generator UserManager::loginUser(http::request res.set(http::field::content_type, "text/plain"); res.keep_alive(req.keep_alive()); res.body() = serializer->serialUserData(user); - std::cout << serializer->serialUserData(user) << std::endl; res.prepare_payload(); return res; } } http::message_generator UserManager::registerUser(http::request &&req) { + std::string login, password, username; + try { - std::string login, password, username; std::tie(login, password, username) = serializer->deserialNewUserData(req.body()); + } catch (...) { + return getBadRequest(req, "Неправильные параметры!"); + } + + try { User user = userService->createUser(login, username, password); http::response res{http::status::ok, req.version()}; res.set(http::field::server, BOOST_BEAST_VERSION_STRING); @@ -58,6 +64,14 @@ http::message_generator UserManager::registerUser(http::requestserialUserData(user); res.prepare_payload(); return res; + } catch (const ValidateException& e) { + http::response res{http::status::forbidden, req.version()}; + res.set(http::field::server, BOOST_BEAST_VERSION_STRING); + res.set(http::field::content_type, "text/plain"); + res.keep_alive(req.keep_alive()); + res.body() = "Не валидные данные"; + res.prepare_payload(); + return res; } catch (...) { return getBadRequest(req, "Something went wrong!"); } diff --git a/server/internal/service/include/Exceptions.h b/server/internal/service/include/ServiceExceptions.h similarity index 96% rename from server/internal/service/include/Exceptions.h rename to server/internal/service/include/ServiceExceptions.h index 5e52658cfefa8343861e9bf53b0b22c418a652c4..aabf3c14d6f418b15a706a4e7b7834fe90bd26b2 100644 --- a/server/internal/service/include/Exceptions.h +++ b/server/internal/service/include/ServiceExceptions.h @@ -1,25 +1,25 @@ -#pragma once - -class ValidateException : public std::exception { - std::string _msg; - - public: - ValidateException(const std::string& msg) : _msg(msg) {} - virtual const char* what() const noexcept override { return _msg.c_str(); } -}; - -class LoginException : public std::exception { - std::string _msg; - - public: - LoginException(const std::string& msg) : _msg(msg) {} - virtual const char* what() const noexcept override { return _msg.c_str(); } -}; - -class FileExtensionException : public std::exception { - std::string _msg; - - public: - FileExtensionException(const std::string& msg) : _msg(msg) {} - virtual const char* what() const noexcept override { return _msg.c_str(); } +#pragma once + +class ValidateException : public std::exception { + std::string _msg; + + public: + ValidateException(const std::string& msg) : _msg(msg) {} + virtual const char* what() const noexcept override { return _msg.c_str(); } +}; + +class LoginException : public std::exception { + std::string _msg; + + public: + LoginException(const std::string& msg) : _msg(msg) {} + virtual const char* what() const noexcept override { return _msg.c_str(); } +}; + +class FileExtensionException : public std::exception { + std::string _msg; + + public: + FileExtensionException(const std::string& msg) : _msg(msg) {} + virtual const char* what() const noexcept override { return _msg.c_str(); } }; \ No newline at end of file diff --git a/server/internal/service/src/SolutionService.cpp b/server/internal/service/src/SolutionService.cpp index 54fb3d193ab1eb30868e732ae0168f965a22b046..b48e53fc27a0cf57df95a8027c701cd0ec900ce7 100644 --- a/server/internal/service/src/SolutionService.cpp +++ b/server/internal/service/src/SolutionService.cpp @@ -11,6 +11,7 @@ #include "ServiceUtils.h" #include "SolutionRepository.hpp" #include "TaskRepository.hpp" +#include "ServiceExceptions.h" const std::string PLAGIAT_VERDICT = "Не, ну вы не палитесь. Плагиат."; const std::string NOT_PLAGIAT_VERDICT = "Красивое решение. А главное уникальное !"; diff --git a/server/internal/service/src/UserService.cpp b/server/internal/service/src/UserService.cpp index f6dc444fb2a3d4a5202b4964c8bfd3096e160ac6..11ceadd905ccdcb7725670a3c8d16a4fa223e4f2 100644 --- a/server/internal/service/src/UserService.cpp +++ b/server/internal/service/src/UserService.cpp @@ -1,6 +1,6 @@ #include "UserService.h" -#include "Exceptions.h" +#include "ServiceExceptions.h" #include "UserRepository.hpp" #include "UserValidator.h" diff --git a/server/internal/service/tests/UserServiceTest.cpp b/server/internal/service/tests/UserServiceTest.cpp index f4828a75dcf95f6e6abab1bfaf2adc3cacb6c257..afb6fe6abadfd0e832834957350ec7669af0d771 100644 --- a/server/internal/service/tests/UserServiceTest.cpp +++ b/server/internal/service/tests/UserServiceTest.cpp @@ -1,7 +1,7 @@ #include #include -#include "Exceptions.h" +#include "ServiceExceptions.h" #include "UserService.h" class Exception : public std::exception {