diff --git a/core/users/userform.cpp b/core/users/userform.cpp index 9394593..dd3edc8 100644 --- a/core/users/userform.cpp +++ b/core/users/userform.cpp @@ -7,11 +7,13 @@ #include "../service.h" #include "../emptystringvalidator.h" #include "../samestringvalidator.h" +#include UserForm::UserForm(QWidget *parent) : AutoForm(parent), ui(new Ui::UserForm) { + m_passChanged = false; ui->setupUi(this); registerBinding(ui->login); registerBinding(ui->password); @@ -54,6 +56,7 @@ void UserForm::bindOtherToUi() ui->tableWidget->setItem(i,0,ti); i++; } + m_passChanged = false; } bool UserForm::bindOtherToData() @@ -66,6 +69,19 @@ bool UserForm::bindOtherToData() this->entity()->addRole(srv.loadById(ui->tableWidget->item(i,0)->data(Qt::UserRole).toInt())); } } + if (m_passChanged){ + this->entity()->setPassword(QString(QCryptographicHash::hash(ui->password->text().toUtf8(),QCryptographicHash::Sha256).toBase64())); + } return true; } + +void UserForm::on_password_textChanged(const QString &arg1) +{ + m_passChanged = true; +} + +void UserForm::on_retypePassword_textChanged(const QString &arg1) +{ + m_passChanged = true; +} diff --git a/core/users/userform.h b/core/users/userform.h index 2abd3a9..c488fdc 100644 --- a/core/users/userform.h +++ b/core/users/userform.h @@ -20,11 +20,15 @@ public: private: Ui::UserForm *ui; + bool m_passChanged; // AutoForm interface protected: void bindOtherToUi(); bool bindOtherToData(); +private slots: + void on_password_textChanged(const QString &arg1); + void on_retypePassword_textChanged(const QString &arg1); }; #endif // USERFORM_H