Skip to content

Commit

Permalink
Show available password retry count in change password form (#65). Ab…
Browse files Browse the repository at this point in the history
…out dialog does show current retry counts (#66)

Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
  • Loading branch information
szszszsz committed May 17, 2016
1 parent 176f3a7 commit d29a9da
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2237,19 +2237,15 @@ void MainWindow::startStickDebug() {
}

void MainWindow::startAboutDialog() {
AboutDialog dialog(cryptostick, this);

if (TRUE == cryptostick->activStick20) {
// Get actual data from stick 20
cryptostick->stick20GetStatusData();

Stick20ResponseTask ResponseTask(this, cryptostick, trayIcon);

ResponseTask.NoStopWhenStatusOK();
ResponseTask.GetResponse();

UpdateDynamicMenuEntrys(); // Use new data to update menu
}
AboutDialog dialog(cryptostick, this);
dialog.exec();
}

Expand Down
44 changes: 43 additions & 1 deletion src/ui/stick20changepassworddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ DialogChangePassword::DialogChangePassword(QWidget *parent)

DialogChangePassword::~DialogChangePassword() { delete ui; }

void DialogChangePassword::UpdatePasswordRetry(){
int retryCount = 0;
// update password retry values
if (TRUE == cryptostick->activStick20) {
cryptostick->stick20GetStatusData();
QSystemTrayIcon trayicon;
Stick20ResponseTask ResponseTask(this, cryptostick, &trayicon );
ResponseTask.NoStopWhenStatusOK();
ResponseTask.GetResponse();
}
cryptostick->getPasswordRetryCount();
cryptostick->getUserPasswordRetryCount();
switch (PasswordKind) {
case STICK20_PASSWORD_KIND_USER:
case STICK10_PASSWORD_KIND_USER:
retryCount = HID_Stick20Configuration_st.UserPwRetryCount;
break;
case STICK20_PASSWORD_KIND_ADMIN:
case STICK10_PASSWORD_KIND_ADMIN:
case STICK20_PASSWORD_KIND_RESET_USER:
case STICK10_PASSWORD_KIND_RESET_USER:
retryCount = HID_Stick20Configuration_st.AdminPwRetryCount;
break;
case STICK20_PASSWORD_KIND_UPDATE:
//FIXME add firmware counter
retryCount = 0;
ui->retryCount->hide();
ui->retryCountLabel->hide();
break;
}
ui->retryCount->setText(QString::number(retryCount));
ui->retryCount->repaint();
}

void DialogChangePassword::InitData(void) {
// center the password window
QDesktopWidget *desktop = QApplication::desktop();
Expand All @@ -80,6 +114,9 @@ void DialogChangePassword::InitData(void) {
QString text = ui->label_additional_information->text();
text = text.arg(minimumPasswordLength).arg(STICK20_PASSOWRD_LEN).arg(minimumPasswordLengthAdmin);
ui->label_additional_information->setText(text);

this->UpdatePasswordRetry();

switch (PasswordKind) {
case STICK20_PASSWORD_KIND_USER:
case STICK10_PASSWORD_KIND_USER:
Expand Down Expand Up @@ -422,8 +459,13 @@ void DialogChangePassword::accept() {
}

cryptostick->getStatus();
if (success)

if (success) {
done(true);
return;
}
this->UpdatePasswordRetry();
this->clearFields();
}

/*******************************************************************************
Expand Down
1 change: 1 addition & 0 deletions src/ui/stick20changepassworddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private slots:
private:
Ui::DialogChangePassword *ui;
void accept(void);
void UpdatePasswordRetry(void);
bool SendNewPassword(void);
void Stick10ChangePassword(void);
void ResetUserPassword(void);
Expand Down
18 changes: 18 additions & 0 deletions ui/stick20changepassworddialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="retryCountLabel">
<property name="text">
<string>Retry count left:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="retryCount">
<property name="text">
<string notr="true">3</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down

0 comments on commit d29a9da

Please sign in to comment.