diff --git a/entities/user_entity.cpp b/entities/user_entity.cpp new file mode 100644 index 0000000..ac98ab6 --- /dev/null +++ b/entities/user_entity.cpp @@ -0,0 +1,21 @@ +#include "user_entity.h" + +user_entity::user_entity(const QString &login, const QString &password, UserRole role) { + this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256); +} + +unsigned long long user_entity::id() { + return this->_id; +} + +const QString user_entity::login() { + return this->_login; +} + +UserRole user_entity::role() { + return this->_role; +} + +bool user_entity::verify_password(const QString &password) { + return (this->_pwd_hash == QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256)); +} diff --git a/entities/user_entity.h b/entities/user_entity.h new file mode 100644 index 0000000..a085969 --- /dev/null +++ b/entities/user_entity.h @@ -0,0 +1,31 @@ +#ifndef USER_ENTITY_H +#define USER_ENTITY_H + +#include +#include + + +enum class UserRole { + ADMINISTRATOR, DISPATCHER, SKIPPER +}; + + +class user_entity +{ +private: + unsigned long long _id; + QString _login; + UserRole _role; + QByteArray _pwd_hash; + +public: + user_entity() = default; + user_entity(const QString &login, const QString &password, UserRole role); + + unsigned long long id(); + const QString login(); + UserRole role(); + bool verify_password(const QString &password); +}; + +#endif // USER_ENTITY_H diff --git a/sea_transport.pro b/sea_transport.pro index 7140f68..a1be585 100644 --- a/sea_transport.pro +++ b/sea_transport.pro @@ -15,6 +15,7 @@ SOURCES += \ entities/cargo_entity.cpp \ entities/dpoint_entity.cpp \ entities/storage_entity.cpp \ + entities/user_entity.cpp \ entities/vessel_entity.cpp \ main.cpp \ storageeditdialog.cpp \ @@ -28,6 +29,7 @@ HEADERS += \ entities/cargo_entity.h \ entities/dpoint_entity.h \ entities/storage_entity.h \ + entities/user_entity.h \ entities/vessel_entity.h \ storageeditdialog.h \ usereditdialog.h \