actual pasword reasking on failed authentication

This commit is contained in:
Blue 2022-04-14 11:13:27 +03:00
parent ce686e121b
commit 8f949277f6
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
13 changed files with 347 additions and 28 deletions

View file

@ -76,16 +76,31 @@ void DialogQueue::performNextAction()
case none:
actionDone();
break;
case askPassword:
prompt = new QInputDialog(squawk);
connect(prompt, &QDialog::accepted, this, &DialogQueue::onPropmtAccepted);
connect(prompt, &QDialog::rejected, this, &DialogQueue::onPropmtRejected);
prompt->setInputMode(QInputDialog::TextInput);
prompt->setTextEchoMode(QLineEdit::Password);
prompt->setLabelText(tr("Input the password for account %1").arg(currentSource));
prompt->setWindowTitle(tr("Password for account %1").arg(currentSource));
prompt->setTextValue("");
prompt->exec();
case askPassword: {
QInputDialog* dialog = new QInputDialog(squawk);
prompt = dialog;
connect(dialog, &QDialog::accepted, this, &DialogQueue::onPropmtAccepted);
connect(dialog, &QDialog::rejected, this, &DialogQueue::onPropmtRejected);
dialog->setInputMode(QInputDialog::TextInput);
dialog->setTextEchoMode(QLineEdit::Password);
dialog->setLabelText(tr("Input the password for account %1").arg(currentSource));
dialog->setWindowTitle(tr("Password for account %1").arg(currentSource));
dialog->setTextValue("");
dialog->exec();
}
break;
case askCredentials: {
CredentialsPrompt* dialog = new CredentialsPrompt(squawk);
prompt = dialog;
connect(dialog, &QDialog::accepted, this, &DialogQueue::onPropmtAccepted);
connect(dialog, &QDialog::rejected, this, &DialogQueue::onPropmtRejected);
Models::Account* acc = squawk->rosterModel.getAccount(currentSource);
dialog->setAccount(currentSource);
dialog->setLogin(acc->getLogin());
dialog->setPassword(acc->getPassword());
dialog->exec();
}
break;
}
}
@ -94,8 +109,18 @@ void DialogQueue::onPropmtAccepted()
switch (currentAction) {
case none:
break;
case askPassword:
emit squawk->responsePassword(currentSource, prompt->textValue());
case askPassword: {
QInputDialog* dialog = static_cast<QInputDialog*>(prompt);
emit squawk->responsePassword(currentSource, dialog->textValue());
}
break;
case askCredentials: {
CredentialsPrompt* dialog = static_cast<CredentialsPrompt*>(prompt);
emit squawk->modifyAccountRequest(currentSource, {
{"login", dialog->getLogin()},
{"password", dialog->getPassword()}
});
}
break;
}
actionDone();
@ -107,6 +132,7 @@ void DialogQueue::onPropmtRejected()
case none:
break;
case askPassword:
case askCredentials:
emit squawk->disconnectAccount(currentSource);
break;
}