Контроль целостности логинов юзеров

This commit is contained in:
2025-08-18 17:19:29 +03:00
parent ef12d4f7a9
commit 037390a9c7
11 changed files with 150 additions and 155 deletions

View File

@@ -123,37 +123,6 @@ int InterfaceDataBaseLMS::delInstructor(int id)
int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
{
//QMutexLocker mtxLocker(&mtxAccess);
//Проверка корректности логина, имени, пароля
if(instructor.getName() == QStringLiteral("<name>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(instructor.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
return 0;
}
if(selectUserID(DataBaseLMS::TypeUserDBInstructor, instructor.getLogin()) || selectUserID(DataBaseLMS::TypeUserDBTrainee, instructor.getLogin()))
{//Логин уже существует!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
return updateInstructor(instructor);
}
@@ -324,26 +293,6 @@ int InterfaceDataBaseLMS::delGroup(int id)
int InterfaceDataBaseLMS::editGroup(Group group)
{
//QMutexLocker mtxLocker(&mtxAccess);
//Проверка корректности имени
QList<Group> listGroups = selectAllGroups();
for(Group exist_group : listGroups)
{
if(group.getName() == QStringLiteral("<group>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
{//Имя уже существует
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing group name has been entered.\nThe changes will not be accepted."));
return 0;
}
}
return updateGroup(group);
}
@@ -440,37 +389,6 @@ int InterfaceDataBaseLMS::delTrainee(int id)
int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
{
//QMutexLocker mtxLocker(&mtxAccess);
//Проверка корректности логина, имени, пароля
if(trainee.getName() == QStringLiteral("<trainee>"))
{//Имя не корректно!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
return 0;
}
if(selectUserID(DataBaseLMS::TypeUserDBInstructor, trainee.getLogin()) || selectUserID(DataBaseLMS::TypeUserDBTrainee, trainee.getLogin()))
{//Логин уже существует!
QMessageBox::critical(ownerWidget, tr("Editing error!"),
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
return updateTrainee(trainee);
}