Сделал коннект и логин

This commit is contained in:
krivoshein
2024-12-03 17:38:06 +03:00
parent 27eda63932
commit c2ada0a8a5
219 changed files with 162385 additions and 1419 deletions

View File

@@ -7,6 +7,7 @@
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::InstructorsAndTraineesWidget),
connectorToServer(nullptr),
dbLMS(nullptr),
viewerTrainees(nullptr),
viewerInstructors(nullptr),
@@ -15,6 +16,9 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
{
ui->setupUi(this);
connectorToServer = new ConnectorToServer(this);
connect(connectorToServer,&ConnectorToServer::sigLoginResult,this,&InstructorsAndTraineesWidget::checkLoginResult);
dbLMS = new InterfaceDataBaseLMS(this);
connect(this, &InstructorsAndTraineesWidget::signal_LanguageChanged, dbLMS, &InterfaceDataBaseLMS::slot_LanguageChanged);
@@ -37,7 +41,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
viewerTrainees->setMinimumSize(1600, 600);
viewerInstructors->setMinimumSize(1600, 300);
ui->btnAuthorizationInstructor->setEnabled(false);
//ui->btnAuthorizationInstructor->setEnabled(false);
//ui->btnConnectionToDB->click();
}
@@ -58,6 +62,7 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
delete viewerInstructors;
delete viewerTrainees;
delete dbLMS;
delete connectorToServer;
delete ui;
}
@@ -90,6 +95,38 @@ void InstructorsAndTraineesWidget::slot_LanguageChanged(QString language)
Q_EMIT signal_LanguageChanged(language);
}
void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverAuth)
{
if (serverAuth->Result)
{
loginInstructorLoggedInLocal = serverAuth->ClientName;
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
adminMode = true;
else
adminMode = false;
viewerInstructors->setAdminMode(adminMode);
viewerTrainees->setAdminMode(adminMode);
viewerInstructors->setAuthComplited(true);
viewerTrainees->setAuthComplited(true);
//Q_EMIT signal_NeedUpdateUI(true, true);
ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor"));
//updateLabelLoggedInInstructor();
//Q_EMIT signal_NeedUpdateUI(true, true);
QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!"));
}
else
{
QMessageBox::warning(this, tr("Instructor authorization"), tr("Invalid login or password!"));
}
}
bool InstructorsAndTraineesWidget::authorizationInstructorLocal(QWidget* parent)
{
DialogAuthorizationInstructor dlg(parent);
@@ -104,30 +141,10 @@ bool InstructorsAndTraineesWidget::authorizationInstructorLocal(QWidget* parent)
QString login = dlg.getLogin();
QString password = dlg.getPassword();
if(authorizationInstructor(login, password))
{
loginInstructorLoggedInLocal = login;
//if(authorizationInstructor(login, password))
connectorToServer->authorizationInstructorLocal(login, password);
if(login == QStringLiteral("admin"))
adminMode = true;
else
adminMode = false;
viewerInstructors->setAdminMode(adminMode);
viewerTrainees->setAdminMode(adminMode);
viewerInstructors->setAuthComplited(true);
viewerTrainees->setAuthComplited(true);
//Q_EMIT signal_NeedUpdateUI(true, true);
QMessageBox::information(parent, tr("Instructor authorization"), tr("Successfully!"));
return true;
}
else
QMessageBox::warning(parent, tr("Instructor authorization"), tr("Invalid login or password!"));
break;
return true;
}
case QDialog::Rejected:
return false;
@@ -366,11 +383,7 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
{//Авторизация Инструктора локальная (Администратора)
if(authorizationInstructorLocal(this))
{
ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor"));
updateLabelLoggedInInstructor();
Q_EMIT signal_NeedUpdateUI(true, true);
}
else
ui->btnAuthorizationInstructor->setChecked(false);
@@ -383,7 +396,7 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
{
ui->btnAuthorizationInstructor->setText(tr("Authorization Instructor"));
updateLabelLoggedInInstructor();
//updateLabelLoggedInInstructor();
Q_EMIT signal_NeedUpdateUI(true, true);
}