-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangemasterkeyform.cpp
More file actions
72 lines (64 loc) · 1.87 KB
/
Copy pathchangemasterkeyform.cpp
File metadata and controls
72 lines (64 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "changemasterkeyform.h"
#include "ui_changemasterkeyform.h"
#include <QtSql>
#include <QMessageBox>
ChangeMasterKeyForm::ChangeMasterKeyForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChangeMasterKeyForm),passwordVisible(false)
{
ui->setupUi(this);
}
ChangeMasterKeyForm::~ChangeMasterKeyForm()
{
delete ui;
}
void ChangeMasterKeyForm::SetDbID(QString id)
{
dbID=id;
}
void ChangeMasterKeyForm::on_buttonBox_Response_accepted()
{
QString masterPass=ui->lineEdit_MasterPass->text(),repeatPass=ui->lineEdit_Repeat->text();
//Validate if the correct password has been entered
if(!passwordVisible)
{
if(masterPass!=repeatPass)
{
QMessageBox::warning(this,tr("Change Master Key"),tr("Make sure that the two passwords match..."));
return;
}
}
QSqlQuery change;
change.prepare("update databases set masterKey=HASHBYTES('sha1','"+masterPass+"') where dbID='"+dbID+"'");
if(change.exec())
{
qDebug()<<"Password changed...";
QMessageBox::information(this,tr("Change Master Key"),tr("Password has been successfully changed..."));
//password changed
this->close();
}
else
{
qDebug()<<change.lastError().text();
}
}
void ChangeMasterKeyForm::on_buttonBox_Response_rejected()
{
this->close();
}
void ChangeMasterKeyForm::on_toolButton_Visible_clicked()
{
//when triggered will allow the user to see the characters being entered
if(passwordVisible)
{
ui->lineEdit_MasterPass->setEchoMode(QLineEdit::EchoMode::Password);
ui->lineEdit_Repeat->setEnabled(true);
passwordVisible=false;
}
else//will hide the characters from the user
{
ui->lineEdit_Repeat->setEnabled(false);
ui->lineEdit_MasterPass->setEchoMode(QLineEdit::EchoMode::Normal);
passwordVisible=true;
}
}