GUI.Тип ошибки авторизации

This commit is contained in:
2025-11-27 16:54:40 +03:00
parent 00c9ec8893
commit bf87a2c982
13 changed files with 182 additions and 42 deletions

View File

@@ -456,16 +456,33 @@ void RecognizeSystem::xmlParser(QByteArray array)
if(name == "Code")
{
if (value == "END")
if (value == NOTIFY_SERVER_END)
{
emit sigSocketDisabled();
}
if(value == "BLOCKED")
if(value == NOTIFY_SERVER_BLOCKED)
{
emit sigServerBlocked();
}
if(value == NOTIFY_ERROR_AUTH_DB)
{
emit sigErrorAuth(value);
}
if(value == NOTIFY_ERROR_AUTH_LOGINORPASSWORD)
{
emit sigErrorAuth(value);
}
if(value == NOTIFY_ERROR_AUTH_ARCHIVED)
{
emit sigErrorAuth(value);
}
if(value == NOTIFY_ERROR_AUTH_ALREADYLOGIN)
{
emit sigErrorAuth(value);
}
if(value == "HASHSENDCOMPLETE")
{
emit sigStartCompare();

View File

@@ -34,6 +34,7 @@ signals:
void sigSendDebugLog(QString message);
void sigSocketDisabled();
void sigServerBlocked();
void sigErrorAuth(QString error);
void sigAuth(ServerAuthorization *serverAuth);
void sigDeAuth(ServerDeAuthorization *serverDeAuth);
void sigAnswerQueryToDB(QList<Instructor>* listInstructors,

View File

@@ -71,6 +71,14 @@ enum PacketType{
FREE = 155
};
#define NOTIFY_ERROR_AUTH_DB "ERROR_AUTH_DB"
#define NOTIFY_ERROR_AUTH_LOGINORPASSWORD "ERROR_AUTH_LOGINORPASSWORD"
#define NOTIFY_ERROR_AUTH_ARCHIVED "ERROR_AUTH_ARCHIVED"
#define NOTIFY_ERROR_AUTH_ALREADYLOGIN "ERROR_AUTH_ALREADYLOGIN"
#define NOTIFY_SERVER_END "END"
#define NOTIFY_SERVER_BLOCKED "BLOCKED"
#define SERVER_HELLO "NewConnection. I am server LMS!"
//Q_DECLARE_METATYPE(PacketType)
class Tools {

View File

@@ -90,6 +90,11 @@ void ConnectorToServer::slot_ServerBlocked()
emit sigServerBlocked();
}
void ConnectorToServer::slot_ErrorAuth(QString error)
{
emit sigErrorAuth(error);
}
void ConnectorToServer::slot_SendDeleteVersion(StreamingVersionData *streaming)
{
emit signal_SendDeleteVersion(streaming);
@@ -133,6 +138,7 @@ void ConnectorToServer::bindConnection()
connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult);
connect(recognizeSystem,&RecognizeSystem::sigServerBlocked,this,&ConnectorToServer::slot_ServerBlocked);
connect(recognizeSystem,&RecognizeSystem::sigErrorAuth,this,&ConnectorToServer::slot_ErrorAuth);
connect(recognizeSystem,&RecognizeSystem::signal_ReceiveMessage,this,&ConnectorToServer::signal_receiveMessage,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigShowServerDataList,this,&ConnectorToServer::slot_showServerList);

View File

@@ -108,6 +108,7 @@ public slots:
void slot_HashReady();
void slot_Auth(ServerAuthorization * serverAuth);
void slot_ServerBlocked();
void slot_ErrorAuth(QString error);
void slot_SendDeleteVersion(StreamingVersionData *streaming);
void slot_SendSwitchVersion(StreamingVersionData *selectVersion);
@@ -125,6 +126,7 @@ signals:
void sigLoginResult(ServerAuthorization * serverAuth);
void sigDeLoginResult(ServerDeAuthorization * serverDeAuth);
void sigServerBlocked();
void sigErrorAuth(QString error);
void signal_UpdateDB(bool treeInstructor, bool treeTrainee);

View File

@@ -54,6 +54,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked);
connect(connectorToServer, &ConnectorToServer::sigErrorAuth, this, &InstructorsAndTraineesWidget::slot_ErrorAuth);
connect(connectorToServer,&ConnectorToServer::signal_AnswerDocsChanged,this, &InstructorsAndTraineesWidget::slot_AnswerDocsChanged);
messangerController = new MessangerController(connectorToServer, this);
@@ -239,16 +240,14 @@ void InstructorsAndTraineesWidget::slot_checkLoginResult(ServerAuthorization *se
viewerInstructors->activate();
waitAnimationWidget->hideWithStop();
flTryLogin = false;
}
else
{
waitAnimationWidget->hideWithStop();
ui->btnAuthorizationInstructor->setChecked(false);
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Instructor authorization.") + "\n" + tr("Invalid login or password!")).exec();
//waitAnimationWidget->hideWithStop();
//ui->btnAuthorizationInstructor->setChecked(false);
}
flTryLogin = false;
}
void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization *serverDeAuth)
@@ -285,7 +284,39 @@ void InstructorsAndTraineesWidget::slot_ServerBlocked()
waitAnimationWidget->hideWithStop();
ui->btnAuthorizationInstructor->setChecked(false);
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server blocked!")).exec();
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec();
}
}
void InstructorsAndTraineesWidget::slot_ErrorAuth(QString error)
{
if(flTryLogin)
{
flTryLogin = false;
waitAnimationWidget->hideWithStop();
ui->btnAuthorizationInstructor->setChecked(false);
QString errorTextMsg = "";
if(error == NOTIFY_ERROR_AUTH_DB)
{
errorTextMsg = tr("Database error!");
}
else if(error == NOTIFY_ERROR_AUTH_ARCHIVED)
{
errorTextMsg = tr("The user is archived!");
}
else if(error == NOTIFY_ERROR_AUTH_ALREADYLOGIN)
{
errorTextMsg = tr("The user is already logged in!");
}
else if(error == NOTIFY_ERROR_AUTH_LOGINORPASSWORD)
{
errorTextMsg = tr("Login or password error!");
}
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec();
}
}

View File

@@ -54,6 +54,7 @@ public Q_SLOTS:
void slot_checkDeLoginResult(ServerDeAuthorization * serverDeAuth);
void slot_ServerBlocked();
void slot_ErrorAuth(QString error);
//Слот обработки результата подключения к серверу
void slot_ConnectedToServer(bool state);