Password hashing support
This commit is contained in:
@@ -7,11 +7,13 @@
|
|||||||
#include "../service.h"
|
#include "../service.h"
|
||||||
#include "../emptystringvalidator.h"
|
#include "../emptystringvalidator.h"
|
||||||
#include "../samestringvalidator.h"
|
#include "../samestringvalidator.h"
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
UserForm::UserForm(QWidget *parent) :
|
UserForm::UserForm(QWidget *parent) :
|
||||||
AutoForm<User>(parent),
|
AutoForm<User>(parent),
|
||||||
ui(new Ui::UserForm)
|
ui(new Ui::UserForm)
|
||||||
{
|
{
|
||||||
|
m_passChanged = false;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
registerBinding(ui->login);
|
registerBinding(ui->login);
|
||||||
registerBinding(ui->password);
|
registerBinding(ui->password);
|
||||||
@@ -54,6 +56,7 @@ void UserForm::bindOtherToUi()
|
|||||||
ui->tableWidget->setItem(i,0,ti);
|
ui->tableWidget->setItem(i,0,ti);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
m_passChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserForm::bindOtherToData()
|
bool UserForm::bindOtherToData()
|
||||||
@@ -66,6 +69,19 @@ bool UserForm::bindOtherToData()
|
|||||||
this->entity()->addRole(srv.loadById(ui->tableWidget->item(i,0)->data(Qt::UserRole).toInt()));
|
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;
|
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:
|
private:
|
||||||
Ui::UserForm *ui;
|
Ui::UserForm *ui;
|
||||||
|
bool m_passChanged;
|
||||||
|
|
||||||
// AutoForm interface
|
// AutoForm interface
|
||||||
protected:
|
protected:
|
||||||
void bindOtherToUi();
|
void bindOtherToUi();
|
||||||
bool bindOtherToData();
|
bool bindOtherToData();
|
||||||
|
private slots:
|
||||||
|
void on_password_textChanged(const QString &arg1);
|
||||||
|
void on_retypePassword_textChanged(const QString &arg1);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USERFORM_H
|
#endif // USERFORM_H
|
||||||
|
|||||||
Reference in New Issue
Block a user