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:
@@ -295,6 +295,16 @@ int ConnectorToServer::getIdTraineeByLogin(QString login)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConnectorToServer::getIdInstructorByLogin(QString login)
|
||||
{
|
||||
for(Instructor instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getLogin() == login)
|
||||
return instructor.getID();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ConnectorToServer::showVersionSelect()
|
||||
{
|
||||
QByteArray answer = dataParser->xmlAnswer_notify(cmd_CheckVersionList);
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
Group getGroup(int id);
|
||||
|
||||
int getIdTraineeByLogin(QString login);
|
||||
int getIdInstructorByLogin(QString login);
|
||||
void showVersionSelect();
|
||||
|
||||
void setLoginName(QString name);
|
||||
|
||||
@@ -270,7 +270,7 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
|
||||
{
|
||||
//Проверка корректности логина, имени, пароля
|
||||
|
||||
if(instructor.getName() == QStringLiteral("<instructor>"))
|
||||
if(instructor.getName() == QStringLiteral("<name>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
|
||||
@@ -292,23 +292,13 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
|
||||
}
|
||||
|
||||
|
||||
QList<Instructor> listInstructors = connectorToServer->getListInstructors();
|
||||
|
||||
for(Instructor exist_instructor : listInstructors)
|
||||
{
|
||||
if(instructor.getName() == exist_instructor.getName() && instructor.getID() != exist_instructor.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor name has been entered."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(instructor.getLogin() == exist_instructor.getLogin() && instructor.getID() != exist_instructor.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
int user_I = connectorToServer->getIdInstructorByLogin(instructor.getLogin());
|
||||
int user_T = connectorToServer->getIdTraineeByLogin(instructor.getLogin());
|
||||
if((user_I && (user_I != instructor.getID())) || (user_T && (user_T != instructor.getID())))
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -24,6 +24,13 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM
|
||||
ui->btnArchive->click();
|
||||
|
||||
waitAnimationWidget->setParent(this);
|
||||
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(false);
|
||||
ui->btnEdit->setEnabled(false);
|
||||
}
|
||||
|
||||
EditorTrainees::~EditorTrainees()
|
||||
@@ -448,7 +455,7 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
|
||||
{
|
||||
//Проверка корректности логина, имени, пароля
|
||||
|
||||
if(trainee.getName() == QStringLiteral("<trainee>"))
|
||||
if(trainee.getName() == QStringLiteral("<name>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
|
||||
@@ -469,23 +476,14 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Trainee> listTrainees = connectorToServer->getListTrainees();
|
||||
|
||||
for(Trainee exist_trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getName() == exist_trainee.getName() && trainee.getID() != exist_trainee.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee name has been entered."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == exist_trainee.getLogin() && trainee.getID() != exist_trainee.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
int user_I = connectorToServer->getIdInstructorByLogin(trainee.getLogin());
|
||||
int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin());
|
||||
if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID())))
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user