Add user entity
This commit is contained in:
parent
4f1b0346c6
commit
8f71fb50a3
3 changed files with 54 additions and 0 deletions
21
entities/user_entity.cpp
Normal file
21
entities/user_entity.cpp
Normal file
|
|
@ -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));
|
||||
}
|
||||
31
entities/user_entity.h
Normal file
31
entities/user_entity.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef USER_ENTITY_H
|
||||
#define USER_ENTITY_H
|
||||
|
||||
#include <QString>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
||||
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
|
||||
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue