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:
@@ -1,12 +1,14 @@
|
||||
#include "dialogeditinstructor.h"
|
||||
#include "ui_dialogeditinstructor.h"
|
||||
#include "hashtools.h"
|
||||
#include <QPushButton>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogEditInstructor),
|
||||
instructorInput()
|
||||
instructorInput(),
|
||||
flNeedHashPassword(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
@@ -16,15 +18,17 @@ DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
|
||||
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||
ui->btnChangePassword->setObjectName("btnChangePassword");
|
||||
|
||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||
|
||||
ui->editPassword->setEnabled(false);
|
||||
//#ifndef PROJECT_TYPE_DEBUG
|
||||
#ifndef PROJECT_TYPE_DEBUG
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
ui->btnViewPassword->setEnabled(false);
|
||||
ui->btnChangePassword->setEnabled(false);
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
@@ -56,8 +60,8 @@ void DialogEditInstructor::setInstructor(Instructor instructor)
|
||||
ui->editPassword->setEnabled(true);
|
||||
ui->btnViewPassword->setEnabled(true);
|
||||
}
|
||||
//else
|
||||
//ui->editPassword->setText("*****");
|
||||
else
|
||||
ui->btnChangePassword->setEnabled(true);
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
@@ -68,7 +72,15 @@ Instructor DialogEditInstructor::getInstructor()
|
||||
|
||||
instructor.setName(ui->editName->text());
|
||||
instructor.setLogin(ui->editLogin->text());
|
||||
instructor.setPassword(ui->editPassword->text());
|
||||
|
||||
if(flNeedHashPassword)
|
||||
{
|
||||
QString psw = ui->editPassword->text();
|
||||
psw = HashTools::hashingMD5string(psw);
|
||||
instructor.setPassword(psw);
|
||||
}
|
||||
else
|
||||
instructor.setPassword(ui->editPassword->text());
|
||||
|
||||
instructor.setIsAdmin(ui->checkIsAdmin->isChecked());
|
||||
instructor.setArchived(ui->checkArchived->isChecked());
|
||||
@@ -116,3 +128,12 @@ void DialogEditInstructor::on_btnViewPassword_released()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
void DialogEditInstructor::on_btnChangePassword_clicked()
|
||||
{
|
||||
ui->editPassword->setEnabled(true);
|
||||
ui->btnViewPassword->setEnabled(true);
|
||||
|
||||
ui->editPassword->setText("");
|
||||
flNeedHashPassword = true;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ private slots:
|
||||
|
||||
void on_btnViewPassword_released();
|
||||
|
||||
void on_btnChangePassword_clicked();
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
@@ -40,6 +42,8 @@ private:
|
||||
Ui::DialogEditInstructor *ui;
|
||||
|
||||
Instructor instructorInput;
|
||||
|
||||
bool flNeedHashPassword;
|
||||
};
|
||||
|
||||
#endif // DIALOGEDITINSTRUCTOR_H
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<width>470</width>
|
||||
<height>286</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -98,6 +98,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnChangePassword">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user