Commit b0981cc1 authored by Martin Straka's avatar Martin Straka

Fixed problem with first login to isds with new QML input dialog

parent fb535bdd
......@@ -32,6 +32,7 @@ Dialog {
id: root
signal finished(string isdsAction, string pwdType, string userName, string pwd)
signal canceled(string isdsAction, string userName)
property int minimumInputSize: parent.width / 2
property string dIsdsAction
......@@ -89,4 +90,5 @@ Dialog {
} // ColumnLayout
onAccepted: finished(dIsdsAction, dPwdType, dUserName, rootpwd.text.toString())
onRejected: canceled(dIsdsAction, dUserName)
}
......@@ -118,7 +118,10 @@ ApplicationWindow {
InputDialogue {
id: inputDialog
onFinished: {
isds.returnInputDialogText(isdsAction, pwdType, userName, pwd)
isds.inputDialogReturnPassword(isdsAction, pwdType, userName, pwd)
}
onCanceled: {
isds.inputDialogCancelPostAction(isdsAction, userName)
}
Connections {
target: isds
......
......@@ -88,14 +88,15 @@ Item {
onClicked: {
if (isNewAccount) {
// Create a new account context data and add to model.
accounts.createAccount(accountModel, sLoginMethod,
if (accounts.createAccount(accountModel, sLoginMethod,
accountNameTextField.text.toString(),
userNameTextField.text.toString(),
passwordTextField.text.toString(),
testAccount.checked, rememberPassword.checked,
useLS.checked, certPathLabelId.text.toString())
// Login to new account.
isds.doIsdsAction("addNewAccount", userNameTextField.text.toString())
useLS.checked, certPathLabelId.text.toString())) {
// Login to new account.
isds.doIsdsAction("addNewAccount", userNameTextField.text.toString())
}
} else {
// Update account context data.
if (accounts.updateAccount(accountModel, sLoginMethod,
......
......@@ -268,10 +268,10 @@ bool Accounts::createAccount(const QVariant &acntModelVariant,
return false;
}
if (userName.isEmpty() || acntName.isEmpty()) {
if (userName.isEmpty() || acntName.isEmpty() || pwd.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Problem while creating account"),
tr("User name or account name has not been specified!"),
tr("User name, password or account name has not been specified!"),
tr("These fields must be filled in."));
return false;
}
......
......@@ -284,7 +284,15 @@ bool IsdsWrapper::isCorrectPassword(const QString &password)
return true;
}
void IsdsWrapper::returnInputDialogText(const QString &isdsAction,
void IsdsWrapper::inputDialogCancelPostAction(const QString &isdsAction,
const QString &userName)
{
if (isdsAction == "addNewAccount") {
emit unsuccessedLoginToIsdsSig(userName);
}
}
void IsdsWrapper::inputDialogReturnPassword(const QString &isdsAction,
const QString &pwdType, const QString &userName, const QString &pwd)
{
if (pwdType == PWD_PWD) {
......@@ -294,7 +302,12 @@ void IsdsWrapper::returnInputDialogText(const QString &isdsAction,
m_isdsSession.isdsCtxMap[userName].pass_phrase = pwd;
doLoginAction(isdsAction, userName);
} else if (pwdType == PWD_CERT) {
m_isdsSession.isdsCtxMap[userName].pass_phrase = pwd;
/* Certificate password can be empty (without password)*/
if (!pwd.isEmpty()) {
m_isdsSession.isdsCtxMap[userName].pass_phrase = pwd;
} else {
m_isdsSession.isdsCtxMap[userName].pass_phrase = "n/a";
}
doLoginAction(isdsAction, userName);
} else if (pwdType == PWD_TOTP) {
m_isdsSession.isdsCtxMap[userName].pass_phrase = pwd;
......@@ -534,10 +547,6 @@ void IsdsWrapper::doLoginAction(const QString &isdsAction,
emit statusBarTextChanged("", false, false);
}
} else {
if (isdsAction == "addNewAccount") {
emit unsuccessedLoginToIsdsSig(userName);
}
}
}
......@@ -579,7 +588,7 @@ bool IsdsWrapper::hasCtxAllLoginData(const QString &isdsAction,
if (m_isdsSession.isdsCtxMap[userName].password.isEmpty()) {
emit openDialogRequest(isdsAction, PWD_PWD, userName,
tr("Enter password: %1").arg(userName),
tr("Password for '%1' missing").arg(m_isdsSession.isdsCtxMap[userName].account_name),
tr("Password for account '%1' missing").arg(m_isdsSession.isdsCtxMap[userName].account_name),
tr("Enter password"),
true);
return false;
......@@ -590,7 +599,7 @@ bool IsdsWrapper::hasCtxAllLoginData(const QString &isdsAction,
if (m_isdsSession.isdsCtxMap[userName].pass_phrase.isEmpty()) {
emit openDialogRequest(isdsAction, PWD_HOTP, userName,
tr("Enter security code: %1").arg(userName),
tr("Security code for '%1' required").arg(m_isdsSession.isdsCtxMap[userName].account_name),
tr("Security code for account '%1' required").arg(m_isdsSession.isdsCtxMap[userName].account_name),
tr("Enter security code"),
true);
return false;
......@@ -615,8 +624,8 @@ bool IsdsWrapper::hasCtxAllLoginData(const QString &isdsAction,
if (m_isdsSession.isdsCtxMap[userName].login_method == USERNAME_PWD_CERT) {
if (m_isdsSession.isdsCtxMap[userName].pass_phrase.isEmpty()) {
emit openDialogRequest(isdsAction, PWD_CERT, userName,
tr("Enter password: %1").arg(userName),
tr("Certificate password for '%1' required").arg(m_isdsSession.isdsCtxMap[userName].account_name),
tr("Enter certificate password: %1").arg(userName),
tr("Certificate password for account '%1' required").arg(m_isdsSession.isdsCtxMap[userName].account_name),
tr("Enter certificate password"),
true);
return false;
......
......@@ -117,6 +117,16 @@ public:
Q_INVOKABLE
bool isCorrectPassword(const QString &password);
/*!
* @brief Do post actions if QML input dialog was canceled.
*
* @param[in] isdsAction ISDS Action string.
* @param[in] userName Account username string.
*/
Q_INVOKABLE
void inputDialogCancelPostAction(const QString &isdsAction,
const QString &userName);
/*!
* @brief Password string from QML input dialog.
*
......@@ -127,7 +137,7 @@ public:
* @param[in] pwd Password or OTP code.
*/
Q_INVOKABLE
void returnInputDialogText(const QString &isdsAction,
void inputDialogReturnPassword(const QString &isdsAction,
const QString &pwdType, const QString &userName, const QString &pwd);
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment