Блокировка Авторизации при Редактировании в ГУИ

This commit is contained in:
2025-10-02 18:36:41 +03:00
parent 05d4e02d02
commit a70c8b5be1
14 changed files with 75 additions and 9 deletions

View File

@@ -263,6 +263,24 @@ QByteArray DataParser::createDeAuthMessage(ClientDeAutorization *deAuth)
return array; return array;
} }
QByteArray DataParser::createQueryBlockAuth(bool block)
{
QByteArray array;
QXmlStreamWriter xmlWriter(&array);
xmlWriter.setAutoFormatting(true);
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement("BlockAuth");
xmlWriter.writeAttribute("Block", block ? "1" : "0");
xmlWriter.writeEndElement();
xmlWriter.writeEndElement();
xmlWriter.writeEndDocument();
return array;
}
void DataParser::createServerSettings(QString address, QString port) void DataParser::createServerSettings(QString address, QString port)

View File

@@ -28,6 +28,8 @@ public:
QByteArray createQueryTasksXMLMessage(QString type); QByteArray createQueryTasksXMLMessage(QString type);
QByteArray createDeAuthMessage(ClientDeAutorization *deAuth); QByteArray createDeAuthMessage(ClientDeAutorization *deAuth);
QByteArray createQueryBlockAuth(bool block);
void createAuthData(ServerAuthorization *serverAuth); void createAuthData(ServerAuthorization *serverAuth);
void createAuthDataOffline(QString username,QString pass); void createAuthDataOffline(QString username,QString pass);
void addRunData(QList<int> displays); void addRunData(QList<int> displays);

View File

@@ -113,6 +113,19 @@ bool ConnectorToServer::sendQueryTasksXML(QString type)
return true; return true;
} }
bool ConnectorToServer::sendQueryBlockAuth(bool block)
{
if (!client->getIsConnected())
{
return false;
}
QByteArray array = dataParser->createQueryBlockAuth(block);
emit sigSendAnswerToServer(array);
return true;
}
void ConnectorToServer::setLoginName(QString name) void ConnectorToServer::setLoginName(QString name)
{ {
versionSelectWidget->setAuthor(name); versionSelectWidget->setAuthor(name);

View File

@@ -30,6 +30,7 @@ public:
bool sendMessage(ClientMessage clientMessage); bool sendMessage(ClientMessage clientMessage);
bool sendQueryTasksXML(QString type); bool sendQueryTasksXML(QString type);
bool sendQueryBlockAuth(bool block);
void SetConnectToServer(); void SetConnectToServer();
void StopConnectToServer(); void StopConnectToServer();

View File

@@ -58,7 +58,7 @@ void ViewerInstructors::changeEvent(QEvent *event)
void ViewerInstructors::on_btnEditorInstructors_clicked() void ViewerInstructors::on_btnEditorInstructors_clicked()
{ {
Q_EMIT signal_BlockAutorization(true); connectorToServer->sendQueryBlockAuth(true);
dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this); dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this);
dlgRedactor->exec(); dlgRedactor->exec();
@@ -72,7 +72,7 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
if(authComplited) if(authComplited)
loadInstructorsFromDB(); loadInstructorsFromDB();
Q_EMIT signal_BlockAutorization(false); connectorToServer->sendQueryBlockAuth(false);
} }
void ViewerInstructors::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column) void ViewerInstructors::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column)

View File

@@ -28,7 +28,7 @@ protected:
Q_SIGNALS: Q_SIGNALS:
//сигнал о блокировке авторизации //сигнал о блокировке авторизации
void signal_BlockAutorization(bool block); //void signal_BlockAutorization(bool block);
public Q_SLOTS: public Q_SLOTS:
void on_btnEditorInstructors_clicked(); void on_btnEditorInstructors_clicked();

View File

@@ -48,8 +48,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
viewerInstructors = new ViewerInstructors(connectorToServer, this); viewerInstructors = new ViewerInstructors(connectorToServer, this);
connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerTrainees, &ViewerTrainees::slot_NeedUpdateUI); connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerTrainees, &ViewerTrainees::slot_NeedUpdateUI);
connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerInstructors, &ViewerInstructors::slot_NeedUpdateUI); connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerInstructors, &ViewerInstructors::slot_NeedUpdateUI);
connect(viewerInstructors, &ViewerInstructors::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization); //connect(viewerInstructors, &ViewerInstructors::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization);
connect(viewerTrainees, &ViewerTrainees::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization); //connect(viewerTrainees, &ViewerTrainees::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization);
connect(connectorToServer, &ConnectorToServer::signal_ConnectedToServer, this, &InstructorsAndTraineesWidget::slot_ConnectedToServer); connect(connectorToServer, &ConnectorToServer::signal_ConnectedToServer, this, &InstructorsAndTraineesWidget::slot_ConnectedToServer);

View File

@@ -60,7 +60,7 @@ Q_SIGNALS:
//сигнал о необходимости обновления интерфейса //сигнал о необходимости обновления интерфейса
void signal_NeedUpdateUI(bool treeInstructor, bool treeTrainee); void signal_NeedUpdateUI(bool treeInstructor, bool treeTrainee);
//сигнал о блокировке авторизации //сигнал о блокировке авторизации
void signal_BlockAutorization(bool block); //void signal_BlockAutorization(bool block);
private Q_SLOTS: private Q_SLOTS:
void on_btnConnectionToServer_clicked(); void on_btnConnectionToServer_clicked();

View File

@@ -92,7 +92,7 @@ void ViewerTrainees::changeEvent(QEvent *event)
void ViewerTrainees::on_btnEditorTrainees_clicked() void ViewerTrainees::on_btnEditorTrainees_clicked()
{ {
Q_EMIT signal_BlockAutorization(true); connectorToServer->sendQueryBlockAuth(true);
dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this); dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this);
dlgRedactor->exec(); dlgRedactor->exec();
@@ -106,7 +106,7 @@ void ViewerTrainees::on_btnEditorTrainees_clicked()
if(authComplited) if(authComplited)
loadTraineesFromDB(); loadTraineesFromDB();
Q_EMIT signal_BlockAutorization(false); connectorToServer->sendQueryBlockAuth(false);
} }
void ViewerTrainees::on_itemDoubleClicked(QTreeWidgetItem *item, int column) void ViewerTrainees::on_itemDoubleClicked(QTreeWidgetItem *item, int column)

View File

@@ -32,7 +32,7 @@ protected:
Q_SIGNALS: Q_SIGNALS:
//сигнал о блокировке авторизации //сигнал о блокировке авторизации
void signal_BlockAutorization(bool block); //void signal_BlockAutorization(bool block);
public Q_SLOTS: public Q_SLOTS:
//void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column); //void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column);

View File

@@ -72,6 +72,11 @@ void ProcessParser::slot_read(ClientHandler *client, QByteArray array)
clientUnityTaskFIMreport(xmlReader,client, array); clientUnityTaskFIMreport(xmlReader,client, array);
} }
} }
else if(xmlReader.name() == "BlockAuth")
{//Запрос Блокировки Авторизации от клиента ГУИ
clientBlockAuth(xmlReader,client);
}
else else
{ {
emit sigLogMessage("XmlParser: unrecognized tag"); emit sigLogMessage("XmlParser: unrecognized tag");
@@ -334,6 +339,24 @@ void ProcessParser::clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *clie
processingSystem->processingClientDeAutorization(client, clientDeAutorization); processingSystem->processingClientDeAutorization(client, clientDeAutorization);
} }
void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *client)
{
bool block = false;
/*Перебираем все атрибуты тега*/
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
{
QString name = attr.name().toString();
QString value = attr.value().toString();
//addTextToLogger(name + ": " + value);
if(name == "Block")
block = (value == "1") ? true : false;
}
processingSystem->processingClientBlockAuth(client, block);
}
void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array) void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array)
{ {
ClientQueryToDB queryToDB; ClientQueryToDB queryToDB;

View File

@@ -25,6 +25,7 @@ private:
ProcessingSystem *processingSystem; ProcessingSystem *processingSystem;
void clientAuth(QXmlStreamReader &xmlReader,ClientHandler *client); void clientAuth(QXmlStreamReader &xmlReader,ClientHandler *client);
void clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *client); void clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *client);
void clientBlockAuth(QXmlStreamReader &xmlReader,ClientHandler *client);
void toClientMessage(QXmlStreamReader &xmlReader,ClientHandler *client); void toClientMessage(QXmlStreamReader &xmlReader,ClientHandler *client);
void queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array = QByteArray()); void queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array = QByteArray());
void queryTasksXML(QXmlStreamReader &xmlReader,ClientHandler *client); void queryTasksXML(QXmlStreamReader &xmlReader,ClientHandler *client);

View File

@@ -101,6 +101,7 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien
void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization) void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization)
{ {
/*
if(server->getStateBlockAutorization() == blocked) if(server->getStateBlockAutorization() == blocked)
{ {
QByteArray arrayAnswer = dataParser->ClientAnswer()->notify(NOTIFY_SERVER_BLOCKED); QByteArray arrayAnswer = dataParser->ClientAnswer()->notify(NOTIFY_SERVER_BLOCKED);
@@ -111,6 +112,7 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
return; return;
} }
*/
//Попытка ДеАвторизации клиента (проверка по БД) //Попытка ДеАвторизации клиента (проверка по БД)
QByteArray arrayAnswer; QByteArray arrayAnswer;
@@ -148,6 +150,11 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
emit sigListsInstructorsTraineesChanged(); emit sigListsInstructorsTraineesChanged();
} }
void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block)
{
emit providerDBLMS->signal_BlockAutorization(block);
}
//упращенная деавторизация при выключении сервера //упращенная деавторизация при выключении сервера
void ProcessingSystem::processingClientDeAutorization(QString login) void ProcessingSystem::processingClientDeAutorization(QString login)
{ {

View File

@@ -34,6 +34,7 @@ public:
void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization); void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization); void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
void processingClientBlockAuth(ClientHandler *client, bool block);
void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr); void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML); void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML);