Skip to content

Commit 0ae8e4f

Browse files
metsmamrts
authored andcommitted
Fix cancel and don't setup OK button when CertificateButton is not found
WE2-573 Signed-off-by: Raul Metsma <[email protected]>
1 parent 1a47fc8 commit 0ae8e4f

File tree

1 file changed

+28
-36
lines changed

1 file changed

+28
-36
lines changed

src/ui/webeiddialog.cpp

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ void WebEidDialog::showAboutPage()
128128
d->ui->pageStack->setCurrentIndex(int(Page::ABOUT));
129129
d->adjustSize();
130130
d->open();
131+
connect(d, &WebEidDialog::finished, qApp, &QApplication::quit);
131132
}
132133

133134
void WebEidDialog::showFatalErrorPage()
@@ -187,46 +188,37 @@ void WebEidDialog::onSmartCardStatusUpdate(const RetriableError status)
187188
void WebEidDialog::onMultipleCertificatesReady(
188189
const QUrl& origin, const std::vector<CardCertificateAndPinInfo>& certificateAndPinInfos)
189190
{
190-
try {
191-
ui->selectCertificateOriginLabel->setText(fromPunycode(origin));
192-
setupCertificateAndPinInfo(certificateAndPinInfos);
193-
194-
switch (currentCommand) {
195-
case CommandType::GET_SIGNING_CERTIFICATE:
196-
setupOK([this] {
197-
try {
198-
if (CertificateButton* button =
199-
qobject_cast<CertificateButton*>(ui->selectionGroup->checkedButton())) {
200-
emit accepted(button->certificateInfo());
201-
} else {
202-
THROW(ProgrammingError, "CertificateButton not found");
203-
}
204-
}
205-
CATCH_AND_EMIT_FAILURE_AND_RETURN()
206-
});
207-
208-
break;
209-
case CommandType::AUTHENTICATE:
210-
// Authenticate continues with the selected certificate to onSingleCertificateReady().
211-
setupOK([this, origin] {
212-
try {
213-
if (CertificateButton* button =
214-
qobject_cast<CertificateButton*>(ui->selectionGroup->checkedButton())) {
191+
ui->selectCertificateOriginLabel->setText(fromPunycode(origin));
192+
setupCertificateAndPinInfo(certificateAndPinInfos);
193+
194+
if (CertificateButton* button =
195+
qobject_cast<CertificateButton*>(ui->selectionGroup->checkedButton())) {
196+
try {
197+
switch (currentCommand) {
198+
case CommandType::GET_SIGNING_CERTIFICATE:
199+
setupOK([this, button] { emit accepted(button->certificateInfo()); });
200+
break;
201+
case CommandType::AUTHENTICATE:
202+
// Authenticate continues with the selected certificate to
203+
// onSingleCertificateReady().
204+
setupOK([this, origin, button] {
205+
try {
215206
onSingleCertificateReady(origin, button->certificateInfo());
216-
} else {
217-
THROW(ProgrammingError, "CertificateButton not found");
218207
}
219-
}
220-
CATCH_AND_EMIT_FAILURE_AND_RETURN()
221-
});
222-
break;
223-
default:
224-
THROW(ProgrammingError, "Command " + std::string(currentCommand) + " not allowed here");
208+
CATCH_AND_EMIT_FAILURE_AND_RETURN()
209+
});
210+
break;
211+
default:
212+
THROW(ProgrammingError,
213+
"Command " + std::string(currentCommand) + " not allowed here");
214+
}
215+
216+
ui->pageStack->setCurrentIndex(int(Page::SELECT_CERTIFICATE));
225217
}
226-
227-
ui->pageStack->setCurrentIndex(int(Page::SELECT_CERTIFICATE));
218+
CATCH_AND_EMIT_FAILURE_AND_RETURN()
219+
} else {
220+
emit failure(QStringLiteral("CertificateButton not found"));
228221
}
229-
CATCH_AND_EMIT_FAILURE_AND_RETURN()
230222
}
231223

232224
/** This slot is used by all commands in case there is only a single certificate available. It

0 commit comments

Comments
 (0)