Abstraction and serialization for entities

This commit is contained in:
Andrew nuark G 2020-12-15 20:17:46 +07:00
parent 5cb96fb793
commit 48ad2f1817
13 changed files with 106 additions and 12 deletions

View file

@ -1,6 +1,6 @@
#include "user_entity.h"
user_entity::user_entity(const QString &login, const QString &password, UserRole role) {
user_entity::user_entity(const QString &login, const QString &password, UserRole role) : _login(login), _role(role) {
this->_pwd_hash = QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256);
}
@ -19,3 +19,11 @@ UserRole user_entity::role() {
bool user_entity::verify_password(const QString &password) {
return (this->_pwd_hash == QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha3_256));
}
void user_entity::serialize(QDataStream &output) {
output << this->_id << this->_login << this->_role << this->_pwd_hash;
}
void user_entity::deserialize(QDataStream &input) {
input >> this->_id >> this->_login >> this->_role >> this->_pwd_hash;
}