Password hashing support
This commit is contained in:
@@ -7,11 +7,13 @@
|
||||
#include "../service.h"
|
||||
#include "../emptystringvalidator.h"
|
||||
#include "../samestringvalidator.h"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
UserForm::UserForm(QWidget *parent) :
|
||||
AutoForm<User>(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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user