mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Хэширование пароля
This commit is contained in:
@@ -15,7 +15,18 @@ DialogEditTrainee::DialogEditTrainee(QWidget *parent) :
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
|
||||
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||
|
||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||
|
||||
ui->editPassword->setEnabled(false);
|
||||
//#ifndef PROJECT_TYPE_DEBUG
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
//#endif
|
||||
|
||||
ui->btnViewPassword->setEnabled(false);
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
|
||||
DialogEditTrainee::~DialogEditTrainee()
|
||||
@@ -34,6 +45,14 @@ void DialogEditTrainee::setTrainee(Trainee trainee)
|
||||
ui->checkArchived->setChecked(trainee.getArchived());
|
||||
ui->checkLoggedIn->setChecked(trainee.getLoggedIn());
|
||||
|
||||
if(trainee.getNeedSetPassword())
|
||||
{
|
||||
ui->editPassword->setEnabled(true);
|
||||
ui->btnViewPassword->setEnabled(true);
|
||||
}
|
||||
//else
|
||||
//ui->editPassword->setText("*****");
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -80,3 +99,13 @@ void DialogEditTrainee::on_btnOK_clicked()
|
||||
{
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_btnViewPassword_pressed()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Normal);
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_btnViewPassword_released()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ private slots:
|
||||
|
||||
void on_btnOK_clicked();
|
||||
|
||||
void on_btnViewPassword_pressed();
|
||||
|
||||
void on_btnViewPassword_released();
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
|
||||
@@ -85,13 +85,28 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnViewPassword">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/eye.png</normaloff>:/resources/icons/eye.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@@ -148,63 +148,14 @@ void EditorTrainees::on_btnNewTrainee_clicked()
|
||||
Trainee trainee;
|
||||
Trainee trainee_edit;
|
||||
|
||||
trainee.setNeedSetPassword(true);
|
||||
|
||||
if(editTrainee(trainee, &trainee_edit))
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group, &trainee_edit);
|
||||
}
|
||||
return;
|
||||
|
||||
/*
|
||||
if(int id_trainee = dbLMS->newTrainee(id_group))
|
||||
{
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
|
||||
DialogEditTrainee dlg(this);
|
||||
|
||||
Trainee trainee = dbLMS->getTrainee(id_trainee);
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
dlg.setTrainee(trainee);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Trainee trainee_edit = dlg.getTrainee();
|
||||
|
||||
if(int id_edit = dbLMS->editTrainee(trainee_edit))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
//setCurrentTrainee(id_edit);
|
||||
setCurrentGroup(id_group);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg.setTrainee(trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
dbLMS->delTrainee(id_trainee);
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
return;
|
||||
default:
|
||||
dbLMS->delTrainee(id_trainee);
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -582,6 +533,13 @@ bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(trainee_edit->getNeedSetPassword())
|
||||
{
|
||||
//Хэшируем пароль
|
||||
trainee_edit->hashingPassword();
|
||||
trainee_edit->setNeedSetPassword(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
|
||||
Reference in New Issue
Block a user