-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangePassword.cpp
More file actions
105 lines (82 loc) · 2.49 KB
/
ChangePassword.cpp
File metadata and controls
105 lines (82 loc) · 2.49 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "ChangePassword.h"
#include "ui_ChangePassword.h"
#include "ExternalFunctions.h"
#include "Global.h"
#include "QMessageBox"
using namespace GlobalNameSpace;
ChangePassword::ChangePassword(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChangePassword)
{
ui->setupUi(this);
}
ChangePassword::~ChangePassword()
{
delete ui;
}
QString ChangePassword::getPass()
{
return this->pass;
}
void ChangePassword::on_led_newpass_textChanged(const QString &arg1)
{
if(ComputePassPow(arg1)==0)
{
ui->qlb_password_power->setStyleSheet("QLabel { background-color: rgb(243, 243, 243);}");
ui->qlb_password_power->setText("");
}
else if(ComputePassPow(arg1)<30 && ComputePassPow(arg1)>0)
{
ui->qlb_password_power->setText("Weak");
ui->qlb_password_power->setStyleSheet("QLabel { background-color : red;}");
}
else if(ComputePassPow(arg1)>=30 && ComputePassPow(arg1)<70 )
{
ui->qlb_password_power->setText("Normal");
ui->qlb_password_power->setStyleSheet("QLabel { background-color : yellow;}");
}
else if(70 <= ComputePassPow(arg1) && ComputePassPow(arg1) <=100)
{
ui->qlb_password_power->setText("Strong");
ui->qlb_password_power->setStyleSheet("QLabel { background-color : green;}");
}
}
void ChangePassword::on_btn_box_accepted()
{
QString pass1 =this->ui->led_newpass->text();
QString pass2 = this->ui->led_cunfirmpass->text();
QString current_pass;
if(Globals::TYPE_USER == DEALER)
{
TNodeUser<Dealer> *temp = &Globals::DEALER_LIST.getByKey(Globals::KEY_USER);
current_pass = temp->getData().getPassword();
}
else if(Globals::TYPE_USER == USER)
{
TNodeUser<Users> *temp = &Globals::USER_LIST.getByKey(Globals::KEY_USER);
current_pass = temp->getData().getPassword();
}
if(ui->led_currentpass->text() ==current_pass)
{
if(ComputePassPow(pass1) < 30)
{
QMessageBox::warning(this,"Warning","Your new password is weak !");
}
else
{
if(pass1 == pass2)
{
this->pass = pass1;
QMessageBox::information(this,"Successfully","Your password changed.");
}
else
{
QMessageBox::information(this,"Not match","Passwords are not same !");
}
}
}
else
{
QMessageBox::information(this,"Warning","Your current password is not currect !");
}
}