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:
@@ -33,6 +33,8 @@ add_library(DataBaseLMS SHARED
|
|||||||
timingoftrainee.cpp
|
timingoftrainee.cpp
|
||||||
timingoftrainee.h
|
timingoftrainee.h
|
||||||
contactModel.h
|
contactModel.h
|
||||||
|
hashtools.cpp
|
||||||
|
hashtools.h
|
||||||
resources.qrc
|
resources.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
14
DataBaseLMS/hashtools.cpp
Normal file
14
DataBaseLMS/hashtools.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "hashtools.h"
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
|
HashTools::HashTools()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString HashTools::hashingMD5string(QString str)
|
||||||
|
{// Вычисление MD5 хэша строки
|
||||||
|
|
||||||
|
QByteArray md5Hash = QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||||
|
return QString(md5Hash);
|
||||||
|
}
|
||||||
15
DataBaseLMS/hashtools.h
Normal file
15
DataBaseLMS/hashtools.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef HASHTOOLS_H
|
||||||
|
#define HASHTOOLS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include "DataBaseLMS_global.h"
|
||||||
|
|
||||||
|
class DATABASELMS_EXPORT HashTools
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HashTools();
|
||||||
|
public:
|
||||||
|
static QString hashingMD5string(QString str);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HASHTOOLS_H
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
#include "hashtools.h"
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
const QString User::TypeUserDBInstructor = "instructor";
|
const QString User::TypeUserDBInstructor = "instructor";
|
||||||
const QString User::TypeUserDBTrainee = "trainee";
|
const QString User::TypeUserDBTrainee = "trainee";
|
||||||
@@ -10,7 +12,14 @@ User::User():
|
|||||||
archived(),
|
archived(),
|
||||||
loggedIn(),
|
loggedIn(),
|
||||||
TypeUserDB(),
|
TypeUserDB(),
|
||||||
isAdmin(false)
|
isAdmin(false),
|
||||||
|
needSetPassword(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void User::hashingPassword()
|
||||||
|
{
|
||||||
|
// Вычисление MD5 хэша
|
||||||
|
password = HashTools::hashingMD5string(password);
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ public:
|
|||||||
|
|
||||||
QString getTypeUserDB(){return TypeUserDB;}
|
QString getTypeUserDB(){return TypeUserDB;}
|
||||||
|
|
||||||
|
bool getNeedSetPassword(){return this->needSetPassword;}
|
||||||
|
void setNeedSetPassword(bool needSetPassword){this->needSetPassword = needSetPassword;}
|
||||||
|
|
||||||
|
void hashingPassword();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString login;
|
QString login;
|
||||||
QString password;
|
QString password;
|
||||||
@@ -34,6 +39,7 @@ protected:
|
|||||||
QString TypeUserDB;
|
QString TypeUserDB;
|
||||||
|
|
||||||
bool isAdmin;
|
bool isAdmin;
|
||||||
|
bool needSetPassword;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USER_H
|
#endif // USER_H
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ DialogAuthorizationInstructor::DialogAuthorizationInstructor(QWidget *parent) :
|
|||||||
ui->editLogin->setProperty("mandatoryField", true);
|
ui->editLogin->setProperty("mandatoryField", true);
|
||||||
ui->editPassword->setProperty("mandatoryField", true);
|
ui->editPassword->setProperty("mandatoryField", true);
|
||||||
|
|
||||||
|
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||||
|
|
||||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||||
|
|
||||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||||
@@ -30,3 +32,13 @@ void DialogAuthorizationInstructor::on_btnLogIn_clicked()
|
|||||||
{
|
{
|
||||||
this->accept();
|
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:
|
private slots:
|
||||||
void on_btnLogIn_clicked();
|
void on_btnLogIn_clicked();
|
||||||
|
|
||||||
|
void on_btnViewPassword_pressed();
|
||||||
|
|
||||||
|
void on_btnViewPassword_released();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DialogAuthorizationInstructor *ui;
|
Ui::DialogAuthorizationInstructor *ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,16 +71,31 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="editPassword">
|
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||||
<property name="font">
|
<item>
|
||||||
<font>
|
<widget class="QLineEdit" name="editPassword">
|
||||||
<pointsize>10</pointsize>
|
<property name="font">
|
||||||
</font>
|
<font>
|
||||||
</property>
|
<pointsize>10</pointsize>
|
||||||
<property name="text">
|
</font>
|
||||||
<string/>
|
</property>
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<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>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -15,8 +15,17 @@ DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
|
|||||||
ui->editLogin->setProperty("mandatoryField", true);
|
ui->editLogin->setProperty("mandatoryField", true);
|
||||||
ui->editPassword->setProperty("mandatoryField", true);
|
ui->editPassword->setProperty("mandatoryField", true);
|
||||||
|
|
||||||
|
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||||
|
|
||||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
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);
|
ui->btnOK->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +51,14 @@ void DialogEditInstructor::setInstructor(Instructor instructor)
|
|||||||
else
|
else
|
||||||
ui->editName->setEnabled(true);
|
ui->editName->setEnabled(true);
|
||||||
|
|
||||||
|
if(instructor.getNeedSetPassword())
|
||||||
|
{
|
||||||
|
ui->editPassword->setEnabled(true);
|
||||||
|
ui->btnViewPassword->setEnabled(true);
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//ui->editPassword->setText("*****");
|
||||||
|
|
||||||
ui->btnOK->setEnabled(false);
|
ui->btnOK->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,3 +106,13 @@ void DialogEditInstructor::on_btnOK_clicked()
|
|||||||
{
|
{
|
||||||
this->accept();
|
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_btnOK_clicked();
|
||||||
|
|
||||||
|
void on_btnViewPassword_pressed();
|
||||||
|
|
||||||
|
void on_btnViewPassword_released();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void verify();
|
void verify();
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,28 @@
|
|||||||
<widget class="QLineEdit" name="editLogin"/>
|
<widget class="QLineEdit" name="editLogin"/>
|
||||||
</item>
|
</item>
|
||||||
<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>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -47,59 +47,17 @@ void EditorInstructors::on_btnNewInstructor_clicked()
|
|||||||
Instructor instructor;
|
Instructor instructor;
|
||||||
Instructor instructor_edit;
|
Instructor instructor_edit;
|
||||||
|
|
||||||
|
instructor.setNeedSetPassword(true);
|
||||||
|
|
||||||
if(editInstructor(instructor, &instructor_edit))
|
if(editInstructor(instructor, &instructor_edit))
|
||||||
{
|
{
|
||||||
waitAnimationWidget->showWithPlay();
|
waitAnimationWidget->showWithPlay();
|
||||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR, 0, &instructor_edit);
|
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_INSTRUCTOR, 0, &instructor_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastCurrentID = 0;
|
||||||
|
|
||||||
return;
|
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()
|
void EditorInstructors::on_btnDeleteInstructor_clicked()
|
||||||
@@ -353,6 +311,13 @@ bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instru
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(instructor_edit->getNeedSetPassword())
|
||||||
|
{
|
||||||
|
//Хэшируем пароль
|
||||||
|
instructor_edit->hashingPassword();
|
||||||
|
instructor_edit->setNeedSetPassword(false);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case QDialog::Rejected:
|
case QDialog::Rejected:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "dialogauthorizationinstructor.h"
|
#include "dialogauthorizationinstructor.h"
|
||||||
#include "dialogsettings.h"
|
#include "dialogsettings.h"
|
||||||
#include "specialmessagebox.h"
|
#include "specialmessagebox.h"
|
||||||
|
#include "hashtools.h"
|
||||||
|
|
||||||
|
|
||||||
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
|
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
|
||||||
@@ -314,6 +315,9 @@ bool InstructorsAndTraineesWidget::authorizationInstructorDialog(QWidget* parent
|
|||||||
QString login = dlg.getLogin();
|
QString login = dlg.getLogin();
|
||||||
QString password = dlg.getPassword();
|
QString password = dlg.getPassword();
|
||||||
|
|
||||||
|
// Вычисление MD5 хэша
|
||||||
|
password = HashTools::hashingMD5string(password);
|
||||||
|
|
||||||
connectorToServer->authorizationInstructorLocal(login, password);
|
connectorToServer->authorizationInstructorLocal(login, password);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -53,5 +53,6 @@
|
|||||||
<file>resources/icons/warning.png</file>
|
<file>resources/icons/warning.png</file>
|
||||||
<file>resources/icons/info.png</file>
|
<file>resources/icons/info.png</file>
|
||||||
<file>resources/icons/personalCard.png</file>
|
<file>resources/icons/personalCard.png</file>
|
||||||
|
<file>resources/icons/eye.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
BIN
InstructorsAndTrainees/resources/icons/eye.png
Normal file
BIN
InstructorsAndTrainees/resources/icons/eye.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
@@ -15,7 +15,18 @@ DialogEditTrainee::DialogEditTrainee(QWidget *parent) :
|
|||||||
ui->editLogin->setProperty("mandatoryField", true);
|
ui->editLogin->setProperty("mandatoryField", true);
|
||||||
ui->editPassword->setProperty("mandatoryField", true);
|
ui->editPassword->setProperty("mandatoryField", true);
|
||||||
|
|
||||||
|
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||||
|
|
||||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
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()
|
DialogEditTrainee::~DialogEditTrainee()
|
||||||
@@ -34,6 +45,14 @@ void DialogEditTrainee::setTrainee(Trainee trainee)
|
|||||||
ui->checkArchived->setChecked(trainee.getArchived());
|
ui->checkArchived->setChecked(trainee.getArchived());
|
||||||
ui->checkLoggedIn->setChecked(trainee.getLoggedIn());
|
ui->checkLoggedIn->setChecked(trainee.getLoggedIn());
|
||||||
|
|
||||||
|
if(trainee.getNeedSetPassword())
|
||||||
|
{
|
||||||
|
ui->editPassword->setEnabled(true);
|
||||||
|
ui->btnViewPassword->setEnabled(true);
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//ui->editPassword->setText("*****");
|
||||||
|
|
||||||
ui->btnOK->setEnabled(false);
|
ui->btnOK->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,3 +99,13 @@ void DialogEditTrainee::on_btnOK_clicked()
|
|||||||
{
|
{
|
||||||
this->accept();
|
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_btnOK_clicked();
|
||||||
|
|
||||||
|
void on_btnViewPassword_pressed();
|
||||||
|
|
||||||
|
void on_btnViewPassword_released();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void verify();
|
void verify();
|
||||||
|
|
||||||
|
|||||||
@@ -85,13 +85,28 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="editPassword">
|
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||||
<property name="font">
|
<item>
|
||||||
<font>
|
<widget class="QLineEdit" name="editPassword">
|
||||||
<pointsize>10</pointsize>
|
<property name="font">
|
||||||
</font>
|
<font>
|
||||||
</property>
|
<pointsize>10</pointsize>
|
||||||
</widget>
|
</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>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -148,63 +148,14 @@ void EditorTrainees::on_btnNewTrainee_clicked()
|
|||||||
Trainee trainee;
|
Trainee trainee;
|
||||||
Trainee trainee_edit;
|
Trainee trainee_edit;
|
||||||
|
|
||||||
|
trainee.setNeedSetPassword(true);
|
||||||
|
|
||||||
if(editTrainee(trainee, &trainee_edit))
|
if(editTrainee(trainee, &trainee_edit))
|
||||||
{
|
{
|
||||||
waitAnimationWidget->showWithPlay();
|
waitAnimationWidget->showWithPlay();
|
||||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group, &trainee_edit);
|
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group, &trainee_edit);
|
||||||
}
|
}
|
||||||
return;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(trainee_edit->getNeedSetPassword())
|
||||||
|
{
|
||||||
|
//Хэшируем пароль
|
||||||
|
trainee_edit->hashingPassword();
|
||||||
|
trainee_edit->setNeedSetPassword(false);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case QDialog::Rejected:
|
case QDialog::Rejected:
|
||||||
|
|||||||
Reference in New Issue
Block a user