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:
@@ -11,6 +11,8 @@ DialogAuthorizationInstructor::DialogAuthorizationInstructor(QWidget *parent) :
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
|
||||
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
|
||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||
@@ -30,3 +32,13 @@ void DialogAuthorizationInstructor::on_btnLogIn_clicked()
|
||||
{
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void DialogAuthorizationInstructor::on_btnViewPassword_pressed()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Normal);
|
||||
}
|
||||
|
||||
void DialogAuthorizationInstructor::on_btnViewPassword_released()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ public:
|
||||
private slots:
|
||||
void on_btnLogIn_clicked();
|
||||
|
||||
void on_btnViewPassword_pressed();
|
||||
|
||||
void on_btnViewPassword_released();
|
||||
|
||||
private:
|
||||
Ui::DialogAuthorizationInstructor *ui;
|
||||
};
|
||||
|
||||
@@ -71,16 +71,31 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</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>
|
||||
|
||||
@@ -15,8 +15,17 @@ DialogEditInstructor::DialogEditInstructor(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);
|
||||
}
|
||||
|
||||
@@ -42,6 +51,14 @@ void DialogEditInstructor::setInstructor(Instructor instructor)
|
||||
else
|
||||
ui->editName->setEnabled(true);
|
||||
|
||||
if(instructor.getNeedSetPassword())
|
||||
{
|
||||
ui->editPassword->setEnabled(true);
|
||||
ui->btnViewPassword->setEnabled(true);
|
||||
}
|
||||
//else
|
||||
//ui->editPassword->setText("*****");
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -89,3 +106,13 @@ void DialogEditInstructor::on_btnOK_clicked()
|
||||
{
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void DialogEditInstructor::on_btnViewPassword_pressed()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Normal);
|
||||
}
|
||||
|
||||
void DialogEditInstructor::on_btnViewPassword_released()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ private slots:
|
||||
|
||||
void on_btnOK_clicked();
|
||||
|
||||
void on_btnViewPassword_pressed();
|
||||
|
||||
void on_btnViewPassword_released();
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
|
||||
@@ -77,7 +77,28 @@
|
||||
<widget class="QLineEdit" name="editLogin"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword"/>
|
||||
</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>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@@ -47,59 +47,17 @@ void EditorInstructors::on_btnNewInstructor_clicked()
|
||||
Instructor instructor;
|
||||
Instructor instructor_edit;
|
||||
|
||||
instructor.setNeedSetPassword(true);
|
||||
|
||||
if(editInstructor(instructor, &instructor_edit))
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR, 0, &instructor_edit);
|
||||
}
|
||||
|
||||
lastCurrentID = 0;
|
||||
|
||||
return;
|
||||
/*
|
||||
if(int id_instructor = dbLMS->newInstructor())
|
||||
{
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(id_instructor);
|
||||
|
||||
DialogEditInstructor dlg(this);
|
||||
|
||||
Instructor instructor = dbLMS->getInstructor(id_instructor);
|
||||
if(instructor.getID() == 0)
|
||||
return;
|
||||
|
||||
dlg.setInstructor(instructor);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Instructor instructor_edit = dlg.getInstructor();
|
||||
|
||||
if(int id_edit = dbLMS->editInstructor(instructor_edit))
|
||||
{//Отредактировано
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(id_edit);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg.setInstructor(instructor_edit);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
dbLMS->delInstructor(id_instructor);
|
||||
loadInstructorsFromDB();
|
||||
return;
|
||||
default:
|
||||
dbLMS->delInstructor(id_instructor);
|
||||
loadInstructorsFromDB();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void EditorInstructors::on_btnDeleteInstructor_clicked()
|
||||
@@ -353,6 +311,13 @@ bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instru
|
||||
continue;
|
||||
}
|
||||
|
||||
if(instructor_edit->getNeedSetPassword())
|
||||
{
|
||||
//Хэшируем пароль
|
||||
instructor_edit->hashingPassword();
|
||||
instructor_edit->setNeedSetPassword(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
|
||||
Reference in New Issue
Block a user